Skip to content
Prev 173861 / 398506 Next

Select a random subset of rows out of matrix

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: