Skip to content
Prev 389159 / 398506 Next

Fastest way to extract rows of smaller matrix many times by index to make larger matrix? and multiply columsn of matrix by vector

Hello Nevil,


you could test something like:


# the Matrix
m = matrix(1:1000, ncol=10)
m = t(m)

# Extract Data
idcol = sample(seq(100), 100, TRUE); # now columns
for(i in 1:100) {
 ??? m2 = m[ , idcol];
}
m2 = t(m2); # transpose back


It may be faster, although I did not benchmark it.


There may be more complex variants. Maybe it is warranted to try for 
10^7 extractions:

- e.g. extracting one row and replacing all occurrences of that row;


Sincerely,


Leonard


========


It seems I cannot extract digested mail anymore. I hope though that the 
message is processed properly.