Hi listers, I am -- View this message in context: http://www.nabble.com/Sample-Function-tp24519071p24519071.html Sent from the R help mailing list archive at Nabble.com.
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 -- View this message in context: http://www.nabble.com/Sample-Function-tp24519230p24519230.html Sent from the R help mailing list archive at Nabble.com.
> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On > Behalf Of MarcioRibeiro > Sent: Thursday, July 16, 2009 8:56 AM > To: r-help at 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, > MarcioTry 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
What is dataset? What is this supposed to be doing? newsample<-dataset[sample(m,replace=T),] --- On Thu, 7/16/09, MarcioRibeiro <mestat at pop.com.br> wrote:> From: MarcioRibeiro <mestat at pop.com.br> > Subject: [R] Sample Function > To: r-help at r-project.org > Received: Thursday, July 16, 2009, 11:55 AM > > 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 > -- > View this message in context: http://www.nabble.com/Sample-Function-tp24519230p24519230.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >__________________________________________________________________ [[elided Yahoo spam]]