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

ProbablePattern picture ProbablePattern · Jul 9, 2010 · Viewed 11.5k times · Source

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.

Answer

Jonathan Chang picture Jonathan Chang · Jul 9, 2010

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