[R] Copying rows from a matrix using a vector of indices

Martin Lam tmlammail at yahoo.com
Wed Aug 17 21:02:07 CEST 2005


Hi,

I am trying to use a vector of indices to select some
rows from a matrix. But before I can do that I somehow
need to convert 'combinations' into a list, since
'mode(combinations)' says it's 'numerical'. Any idea
how I can do that?

library("combinat")

combinations <- t(combn(8,2))

indices <- c(sample(1:length(combinations),10))

# convert
???

subset <- combinations[indices]

Thanks in advance,

Martin




More information about the R-help mailing list