Thank you very much!! To trouble you again: I cannot do the sum and i have looked at several package since startng with this problem. I have a very large code just to do simple random, normal stratified sampling with proportional allocation and Dollar stratification with Neyman allocation using that dataframe i created. Now the code its becoming very large i just wish i could just call everything by the same name it was called in the original data frame, i tried usiing attach with no success. Therefore if you can just help me calculate the sum and mean then i will learn how to shorten this code. Thanks once again you really helped a lot.Thanks
--- On Fri, 2/10/09, Bernardo Rangel Tura <t...@centroin.com.br> wrote: From: Bernardo Rangel Tura <t...@centroin.com.br> 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, 10:08 AM On Fri, 2009-10-02 at 00:42 +0000, KABELI MEFANE wrote: > Thanks > > But it seems like you don't get my problem.Do you mean that there is > something wrong with the code as it seems like what you are doing is > suggesting different ways to write a code. > > Will i get to use the variable that have been name previously like if i want > to calculate the standard deviation of stratum hypermarket in a sample not > population, the first start is to check if it would help me is to check the > length() of different levels if it is not same as that of the original data > > Best Regards > > I rest my case, i might dream it Sorry I don't understand your problem early. In your case you have 2 data.frames: sampleframe and sample.strat so you need show to R where calculate sd or length or summary set.seed(1)# only to make this example don't use in your code stra<-strata(sampleframe,c("type"),size=c(20,80,200,300,400),method="srswor") sample.strat<-getdata(sampleframe,stra) length of value in sampleframe where type is Hypermarket: > length(sampleframet$value[sampleframe$type=="Hypermarket"]) [1] 100 SD of value in sampleframe where type is Hypermarket: > sd(sampleframe$value[sampleframet$type=="Hypermarket"]) [1] 4586.854 length of value in sample.strat where type is Hypermarket: > length(sample.strat$value[sample.strat$type=="Hypermarket"] ) [1] 20 SD of value in sample.strat where type is Hypermarket: > sd(sample.strat$value[sample.strat$type=="Hypermarket"] ) [1] 4679.336 -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil [[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.