Dear group, I would like to generate a 1000 random rows from a MATRIX with dimensions 12,000 by 20 (i.e. to generate a 1000 by 20 matrix of random rows) Does the function sample() work for this??? thank you in advance [[alternative HTML version deleted]]
Is something like this what your looking for: x <- matrix(c(rnorm(100)),ncol=10) sub <- sample(5, replace=TRUE) # For sampling with replacement x[sub,] Harold -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of mark salsburg Sent: Wednesday, March 15, 2006 4:02 PM To: R-help at stat.math.ethz.ch Subject: [R] generating RANDOM ROWS from matrix Dear group, I would like to generate a 1000 random rows from a MATRIX with dimensions 12,000 by 20 (i.e. to generate a 1000 by 20 matrix of random rows) Does the function sample() work for this??? thank you in advance [[alternative HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
?sample You must use replace=FALSE to guarantee 1000 different rows mymatrix[sample(12000,1000,replace=FALSE),] -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of mark salsburg > Sent: Wednesday, March 15, 2006 1:02 PM > To: R-help at stat.math.ethz.ch > Subject: [R] generating RANDOM ROWS from matrix > > Dear group, > > I would like to generate a 1000 random rows from a MATRIX > with dimensions > 12,000 by 20 (i.e. to generate a 1000 by 20 matrix of random rows) > > Does the function sample() work for this??? > > thank you in advance > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >