Efficient way to fill a 3D array
问题 I’m trying to find an efficient way to fill a 3D array. In particular, I want to fill the array's columns with the values of the previous columns. Here is a reproducible example. set.seed(1234) no_ind <- 10 time_period <- 8 ## Define the 3D array col_array <- c(paste("day_", seq(0, 7, 1), sep="")) test <- array(0, dim=c(time_period, length(col_array), no_ind), dimnames=list(NULL, col_array, as.character(seq(1, no_ind, 1)))) print(test) ## Initialize the array test[1,c("day_0"),] <- round