Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming array dimensions gives error: length of 'dimnames' not equal to array extent

This is my first time using a 3 dimensional array and I am having problems about naming the third dimension.

ReplicateData <- array(0, c(240, 500, 5), dimnames=list(NULL, NULL, c("Returns", "Replicates", "Asset Class")))

I am getting the error:

Length of dimnames not equal to array extent

This seems like it should be a simple issue but I can't find an explicit example in the help docs or online.

like image 879
ProbablePattern Avatar asked Jul 09 '10 02:07

ProbablePattern


2 Answers

Since I understand answers better with a bit 'o code to guide me... here is Jonathan Chang's correct answer translated to code:

ReplicateData <- array(0,c(240,500,5),dimnames=list(NULL, NULL, 
  c("Returns","Replicates","Asset Class", "Fourth Dimname", "Fifth Dimname")))
like image 131
D. Woods Avatar answered Oct 27 '22 14:10

D. Woods


The third dimension of your array is of extent 5, but the vector of names for that dimension is of length three.

like image 20
Jonathan Chang Avatar answered Oct 27 '22 12:10

Jonathan Chang