Skip to content
Back to formatted view

Raw Message

Message-ID: <CAEHuMtu61ueoRTpROhmQs9==qHYcvrdw3rg42i-4KYcebGsGNA@mail.gmail.com>
Date: 2012-11-11T16:33:11Z
From: Clemontina Davenport
Subject: Multiplying elements of a list by rows of a matrix

Hi all,
I have the following code:

set.seed(1)
x1 <- matrix(sample(1:12), ncol=3)
x2 <- matrix(sample(1:12), ncol=3)
x3 <- matrix(sample(1:12), ncol=3)
X <- list(x1,x2,x3)
tt <- matrix(round(runif(5*4),2), ncol=4)

Is there a way I can construct a new list where
newlist[[i]] = tt[i,] %*% X[[i]]
without using a for loop? Each element of newlist will be 3 x 1 vector.

Thanks
--
Tina Alexander