[R] Fastest way to extract rows of smaller matrix many times by index to make larger matrix? and multiply columsn of matrix by vector
nev||@@mo@ @end|ng |rom gm@||@com
Tue Sep 14 11:10:46 CEST 2021
OK thanks, I thought it probably was, but always worth asking. the
multiplication of the columns of M2 by V2 is as intended - not matrix
On Tue, 14 Sept 2021 at 17:49, Jeff Newmiller <jdnewmil using dcn.davis.ca.us>
> That is about as fast as it can be done. However you may be able to avoid
> doing it at all if you fold V2 into a matrix instead. Did you mean to use
> matrix multiplication in your calculation of M3?
> On September 13, 2021 11:48:48 PM PDT, nevil amos <nevil.amos using gmail.com>
> >Hi is there a faster way to "extract" rows of a matrix many times to for a
> >longer matrix based in a vector or for indices than M[ V, ]
> >I need to "expand" ( rather than subset) a matrix M of 10-100,000 rows x
> >~50 columns to produce a matrix with a greater number (10^6-10^8) of rows
> >using a vector V containing the 10^6 -10^8 values that are the indices of
> >the rows of M. the output matrix M2 is then multiplied by another vector
> >With the same length as V.
> >Is there a faster way to achieve these calculations (which are by far the
> >slowest portion of a function looped 1000s of times? than the standard M2
> ><- M[ V, ] and M3<-M2*V2, the two calculations are taking a similar time,
> >Matrix M also changes for each loop.
> >x = 10^7
> >times=5,unit = "ms"))
> >thanks for any suggestions
> >Nevil Amos
> > [[alternative HTML version deleted]]
> >R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >PLEASE do read the posting guide
> >and provide commented, minimal, self-contained, reproducible code.
> Sent from my phone. Please excuse my brevity.
[[alternative HTML version deleted]]
More information about the R-help