Yes, thank you. I was able to resolve the issue using this code:
as.matrix(newX%*%Diagonal(length(beta), x=beta))
On Tuesday, September 30, 2014 3:38 AM, peter dalgaard wrote:
On 30 Sep 2014, at 03:47 , Jeff Newmiller wrote:
> library(Matrix)
> result <- newX %*% Diagonal( unlist(beta) )
T
On 30 Sep 2014, at 03:47 , Jeff Newmiller wrote:
> library(Matrix)
> result <- newX %*% Diagonal( unlist(beta) )
The code in Matrix does this efficiently, I hope?
Otherwise, sweep() is the traditional ticket:
result <- sweep(newX, 2, unlist(beta), "*")
Some of my students do
t(t(newX) * unl
library(Matrix)
result <- newX %*% Diagonal( unlist(beta) )
Is beta really a list, or is it a vector? The str function can help with
this... in most cases it is a numeric mode vector and the unlist is not needed.
---
Jeff New
Hi,
I'm trying to use a function to multiply a matrix (newX) with a simple list
(beta).
I know that I can simply use matrix multiplication i.e. newX %*%as.matrix(beta)
and this works fine. However, the matrix multiplication gives me the sum of
each row. What I really need are the new values of a
4 matches
Mail list logo