[R] Selecting Random Subset From Matrix - retaining indices

From: Laura Quinn <laura_at_env.leeds.ac.uk>
Date: Sun 29 Jan 2006 - 05:27:54 EST


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@env.leeds.ac.uk



R-help@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 Received on Sun Jan 29 05:44:57 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:14 EST