开发者

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"开发者_StackOverflow)))

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.


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


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")))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜