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
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
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 matches
Mail list logo