I have an array of dim 4x1x4x71x128. The first dim refers to 4 different models. The third dim refers to lower CI, Correlation, Upper CI and p-value.
What I need as output is a new array of dim 1x1x1x71x128 where the first dim refers to the max value of Correlation(3rd dim) among the 4 models(1st dim).
I tried the following:
newarray <- array(NA, c(1,1,1,71,128))
for (i in 1:4) {
for (j in 1:nrow(array[1,1,1,,])) {
for (k in 1:ncol(array[1,1,1,,])){
newarray[i,1,1,j,k] <- max(array[i,1,1,j,k], na.rm = FALSE)
}
}
}
This returns me the maximum value not for Correlation but for lower CI. However, when I change operation to:
newarray[i,1,1,j,k] <- max(array[i,1,2,j,k], na.rm = FALSE)
It does not work. I believe I am not looping right but can't seem to figure it out.
Thanks for you help in advance!