[R] Selecting Random Subset From Matrix - retaining indices
Laura Quinn
laura at env.leeds.ac.uk
Sat Jan 28 19:27:54 CET 2006
Hello,
I was wondering whether there is a way to select random samples from a
data matrix, retaining the indexing for the rows and columns? I have
looked at using the sample() function. Applied directly to my matrix this
returns a vector of absolute values but the indices are lost, alternatively I can
select a random sample from a length equal to the number of elements in
the matrix and then translate each number into an element withing the
array but this seems to require a lot of work to ascertain the position
and value of each element. Is there a better way of performing this
operation?
Further to my earlier query I am hoping to pick a random selection of
grid points (with (x,y,z) coords) from a 3d map matrix.
Thanks in advance.
Laura Quinn
Institute of Atmospheric Science
School of Earth and Environment
University of Leeds
Leeds
LS2 9JT
tel: +44 113 343 1596
fax: +44 113 343 6716
mail: laura at env.leeds.ac.uk
More information about the R-help
mailing list