I have array and df below:
my.df <- data.frame(cbind(c("a1","a2","a3","a4","a5","a6","a7","a8","a9","a10"), c(1:10)))
arr <- array(0, dim = c(2,3,10))
I want each element in my array gets its name from the corresponding row of my df. meaning for example, first element of array must be names a1, senod must be named a2 and so one.
for( i in q:nrow(my.df)){
dimnames(arr[,,i])[[3]] <- my.df[i,1]
}
this is what I m trying to do, which is not working. how can I get to this?