> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of MarcioRibeiro
> Sent: Thursday, July 16, 2009 8:56 AM
> To: r-help@r-project.org
> Subject: [R] Sample Function
> 
> 
> Hi listers,
> Suppose I have a dataset with n=10 observations and I want to sample with
> replacement.
> My new sample is of size m=9.
> So, I am using the following code...
> newsample<-dataset[sample(m,replace=T),]
> The problem is that generates the new sample and the last observation of my
> data set is never included.
> I can sample the identification like this code...
> newsample<-sample(1:n,m,replace=TRUE)
> But, after this code I am obtaining a statistic and I have only the
> identification of the data observed.
> Is there a way that I can sample the data observed to calculate a statistic
> of it.
> Thanks in advance,
> Marcio

Try

newsample<-dataset[sample(1:10,m,replace=TRUE),]

Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204

______________________________________________
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