Re: [R] HOw to achieve big vector times big dataframe in R?

2013-03-14 Thread Uwe Ligges
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

Re: [R] HOw to achieve big vector times big dataframe in R?

2013-03-14 Thread Jan van der Laan
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 schreef: HI, I have the following question: Vector a with lenght 150 A B

[R] HOw to achieve big vector times big dataframe in R?

2013-03-14 Thread Tammy Ma
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*