Skip to content

Select a random subset of rows out of matrix

3 messages · Haenlein.Michael, David Winsemius, Paul Hiemstra

#
On Mar 16, 2009, at 10:34 AM, Haenlein.Michael wrote:

            
bigmatrix[ sample( 1:nrow(bigmatrix), 1000, replace=FALSE), ]
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
Hi,

You could try something like this:

nrow = 1000
ncol = 10
nosample = 50
m = matrix(runif(10000), nrow = nrow, ncol = ncol)
# Randomly select 50 row numbers and extract the data
m_subset = m[sample(1:nrow, size = nosample),]

cheers,
Paul
Haenlein.Michael wrote: