Wednesday, January 16, 2013 2:59 AM
Subject: [R] matrix manipulation with its rows
Dear R users,
I have a question about matrix manipulation with its rows.
Plz see the simple example below
sample <- list(matrix(1:6, nr=2,nc=3), matrix(7:12, nr=2,nc=3),
matrix(13:18,nr=2,nc=3))
> sample
[[1]
Not a great solution, I don't think, but:
> kronecker(diag(2), matrix(1:6, 2, byrow=TRUE))[c(1,4),]
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]123000
[2,]000456
So using a function that does this in 'lapply'
should solve the problem you state. I'm gue
ect.org] On Behalf Of Kathryn Lord
> Sent: Wednesday, January 16, 2013 9:00 AM
> To: r-help@r-project.org
> Subject: [R] matrix manipulation with its rows
>
> Dear R users,
>
> I have a question about matrix manipulation with its rows.
>
> Plz see the simple example bel
Dear R users,
I have a question about matrix manipulation with its rows.
Plz see the simple example below
sample <- list(matrix(1:6, nr=2,nc=3), matrix(7:12, nr=2,nc=3),
matrix(13:18,nr=2,nc=3))
> sample
[[1]]
[,1] [,2] [,3]
[1,]135
[2,]246
[[2]]
[,1] [,2] [,
4 matches
Mail list logo