Re: [R] Random subset

2008-07-30 Thread Marc Schwartz
on 07/30/2008 01:28 PM Marc Schwartz wrote: on 07/30/2008 01:18 PM Alessandro wrote: Hi all, I wish to do a random subset (i.e. 200 or 300 points) from a dataset, but I don't find the right code in R. See ?sample. Randomly select 10 elements from a 30 element vector: Vec <- 1:30 > sam

Re: [R] Random subset

2008-07-30 Thread Marc Schwartz
on 07/30/2008 01:18 PM Alessandro wrote: Hi all, I wish to do a random subset (i.e. 200 or 300 points) from a dataset, but I don't find the right code in R. See ?sample. Randomly select 10 elements from a 30 element vector: Vec <- 1:30 > sample(Vec, 10) [1] 16 5 10 29 27 30 21 1 12 28

Re: [R] Random subset

2008-07-30 Thread Roland Rau
But probably you will need to set replace=FALSE if you want to sample from your original data set without replacement. Sorry for the possible confusion, Roland Roland Rau wrote: Hi, check ?sample n <- 200 mydata.set <- rnorm(10) my.random.subset <- sample(x=mydata.set, size=n, replace=T

Re: [R] Random subset

2008-07-30 Thread Roland Rau
Hi, check ?sample n <- 200 mydata.set <- rnorm(10) my.random.subset <- sample(x=mydata.set, size=n, replace=TRUE) my.random.subset I hope this helps, Roland Alessandro wrote: Hi all, I wish to do a random subset (i.e. 200 or 300 points) from a dataset, but I don't find the right

Re: [R] Random subset

2008-07-30 Thread John Kane
?sample --- On Wed, 7/30/08, Alessandro <[EMAIL PROTECTED]> wrote: > From: Alessandro <[EMAIL PROTECTED]> > Subject: [R] Random subset > To: r-help@r-project.org > Received: Wednesday, July 30, 2008, 2:18 PM > Hi all, > > > > I wish to do a random subset (i.e. 200 or 300 points) from > a dat