I wrote a code to compute the amount of second data set when the amount of the first data set is maximum but at the end for some latitude and longitude I got very large number which is not in the first data set. Here is the core of the code:
PW.storm <- array(NA,dim=c(length(lon1),length(lat1))) for (i in 1:length(lon1)){ for (j in 1:length(lat1)){ for (k in 1:length(time)){ t <- time.when.dat1.max <- which.max(abs(dat1[i,j,])) PW.storm[i,j] <- abs(dat2[i,j,t]) } } }
which.max- read?which.maxand trywhich(x == max(x)as an alternative if you have ties.