Another Grad student
Another Grad student

Reputation: 197

Getting dimensions of matrix from a list of matrix in R

I want to store a list of matrices. I do this by constructing matrices using matrix and concatenating it using list. Essentially, suppose I have:

A = matrix(1,2,2)
B = list(A,A)

Then how do I obtain the dimensions of A from B alone? I can obtain a matrix element using B[1], but cannot extract the dimensions. Please help.

Upvotes: 0

Views: 1534

Answers (1)

Mallory
Mallory

Reputation: 51

dim(B[[1]]) will tell you the first matrix in list B has dimensions 2 by 2

Upvotes: 1

Related Questions