Dear Mr Winsemius
 
I am sorry to have offended any of you by the mistakes i made. The package i 
loaded is sampling and there was an unwanted comma between size c(20, )and the 
bracket. What i wanted was to calculate the sum of H in a sample not in the 
original dataframe. If i do 
sum(H) i get the sum value of H's in the original dataframe.
 
 
Load package sampling
 
H <- matrix(rnorm(100, mean=50000, sd=5000))
sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe
 sum(H)

str=strata(sampleframe,c("type"),size=c(20), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat
 
Thanks for the input. Once again sorry for wasting your time.
 
Best Regards 
 
 


--- On Fri, 2/10/09, David Winsemius <dwinsem...@comcast.net> wrote:


From: David Winsemius <dwinsem...@comcast.net>
Subject: Re: [R] How to use Subpopulation data?
To: "KABELI MEFANE" <kabelimef...@yahoo.co.uk>
Cc: R-help@r-project.org
Date: Friday, 2 October, 2009, 3:38 PM



On Oct 1, 2009, at 6:06 AM, KABELI MEFANE wrote:

> Dear Helpers
> 
> I have a sample frame and i have sampled from it using three methods and now 
> i want to calculate the statistics but i only get the population parameters.
> 
> H <- matrix(rnorm(100, mean=50000, sd=5000))
> sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
> sampleframe
> 
> str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
> sample.strat<-getdata(sampleframe,str)
> sample.strat

If you want the number of rows in sample.strat then length(H) is the wrong 
approach since that is the original (unsampled) object.

> length(H)
> i get:
> 
> length(H)
> [1] 100
> 
> Desire to get:
> length(H)
> [1] 20

I cannot tell what packages you have loaded and strata is not in the sampling 
package which I guessed (wrongly) was where you were getting "getdata". When 
you post code you should precede that code with calls that load any non-base 
packages.

In later posting you ask for ways to calculate "the sum" but you do not say 
what it is that you want the sum of.... . Our abilities to read minds is 
extremely limited.

--David Winsemius



      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to