[R] R HELP! How to create a matrix consisting of several matrices in R?
arun
smartpink111 at yahoo.com
Tue Aug 20 19:49:17 CEST 2013
Hi,
May be this helps:
A<- matrix(list(),3,3)
A[[1]]<- matrix(1,4,4)
A[[2]]<- matrix(1:15,3,5)
A[[3]]<- matrix(1:10,5,2)
---------------------------
str(A)
#List of 9
# $ : num [1:4, 1:4] 1 1 1 1 1 1 1 1 1 1 ...
# $ : int [1:3, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
# $ : int [1:5, 1:2] 1 2 3 4 5 6 7 8 9 10
# $ : NULL
# $ : NULL
# $ : NULL
# $ : NULL
# $ : NULL
# $ : NULL
#- attr(*, "dim")= int [1:2] 3 3
A
# [,1] [,2] [,3]
#[1,] Numeric,16 NULL NULL
#[2,] Integer,15 NULL NULL
#[3,] Integer,10 NULL NULL
is.matrix(A)
#[1] TRUE
A.K.
How to create a matrix consisting of several matrices in R?
I let A=matrix("list",3,3) in R then put A[1,1] <- matrix(1,4,4) But it returns error.
Please help. Thank you all.
More information about the R-help
mailing list