[R] How to select randomly from a matrix?
ayuazwal at yahoo.com
Mon Mar 9 16:17:47 CET 2009
Thanks, it works..
Domenico Vistocco wrote:
> WXE83 wrote:
>> Dear all,
>> I got one problem here and hoping someone can help me on this. Say I have
>> 50 by 2 matrix and I don't know how to randomly select:
> data <- matrix(1:25, 50, 2)
>> 1. a pair of observations from the last 10th of the 50 observation from
> data[sample(41:50, 1, replace=FALSE),]
>> 2. how to select randomly an observation from the first 5 observations of
>> the second column in the matrix?
> data[sample(1:5, 1, replace=FALSE),2]
>> Thanks....hope to hear from someone soon
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
View this message in context: http://www.nabble.com/How-to-select-randomly-from-a-matrix--tp22410551p22413454.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help