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))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…