An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130314/5b9467db/attachment.pl>
HOw to achieve big vector times big dataframe in R?
3 messages · Tammy Ma, Jan van der Laan, Uwe Ligges
apply((t(as.matrix(b)) * a), 2, sum) should do what you want. Why this works; see, http://cran.r-project.org/doc/manuals/r-release/R-intro.html#The-recycling-rule and the paragraph before that. Jan Tammy Ma <metal_licaling at live.com> schreef:
HI, I have the following question: Vector a with lenght 150 A B C D......... dataframe b with dim 908X150 1 1 1 1..... 2 2 2 2 3 3 3 3 4 4 4 4 ................ final result I want is the vector with length 908: A*1+B*1+C*1+D*1+..... A*2+B*2+C*2+D*2+..... A*3+B*3+C*3+D*3+..... A*4+B*4+C*4+D*4+..... .... because of too large dimension, how can I achieve this in R? Thanks. Kind Regards, Tammy [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On 14.03.2013 11:27, Jan van der Laan wrote:
apply((t(as.matrix(b)) * a), 2, sum)
... where colSums(.) should be faster than apply(., 2, sum), Uwe Ligges
should do what you want. Why this works; see, http://cran.r-project.org/doc/manuals/r-release/R-intro.html#The-recycling-rule and the paragraph before that. Jan Tammy Ma <metal_licaling at live.com> schreef:
HI,
I have the following question:
Vector a with lenght 150
A B C D.........
dataframe b with dim 908X150
1 1 1 1.....
2 2 2 2
3 3 3 3
4 4 4 4
................
final result I want is the vector with length 908:
A*1+B*1+C*1+D*1+.....
A*2+B*2+C*2+D*2+.....
A*3+B*3+C*3+D*3+.....
A*4+B*4+C*4+D*4+.....
....
because of too large dimension, how can I achieve this in R? Thanks.
Kind Regards,
Tammy
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.