How to change order of array dimensions

前端 未结 1 956
滥情空心
滥情空心 2020-12-02 20:33

How do I reorder the dimensions of an n dimensional array. For example, if I have a three dimensional array of sales data, where the first dimension represents the Date, th

相关标签:
1条回答
  • 2020-12-02 21:05

    The function for doing that is aperm, from the base package. It is a generalization of the transpose t() function to multidimensional arrays. For your example, you would call it as follows:

    new.data <- aperm(old.data, c(2,3,1))
    
    0 讨论(0)
提交回复
热议问题