Displaying 1 result from an estimated 1 matches for "2130220".
Did you mean:
20130220
2008 Jan 30
4
Multiplying each row of a big matrix with a vector
I have a big matrix 'ret'. I want to multiply each row of it with a 2nd vector 'pos', resulting result, I want to save in a vector named 'port'. I wrote following code:
> pos
[1] 2593419 2130220 6198197 1673888 1980000 1784732 2052120 -7490228 -5275000
> dim(ret)
[1] 500 9
> fu # user defined function
function(x)
{
fu = x %*% t(pos)
}
port = apply(ret, 1, fu)
> dim(port)
[1] 81 500
My desire is to get port as a vector with length 500. However I...