I have a problem with the following code for my simple correlation:
x_cor_1<-MW_1982_1996_T
y_cor_2<-NDVI_1997_2011_MW
corvec<- function(vec=NULL){cor(x= vec[1:(length(vec)/2)], y= vec[((length(vec)/2)+1):length(vec)], use = 'complete.obs', method='spearman')}
l_all<-rast(list(x_cor_1,y_cor_2))
corlyrs<- app(l_all, fun=function(x) {if(all(is.na(x))) {NA_real_} else {corvec(vec=x)}})
The error code always comes up: Fehler: [app] the number of values returned by 'fun' is not appropriate
--> x_cor_1: Mean value of temperature over 15 years (right side of picture)
--> y_cor_2: Mean value of NDVI over 15 years (Left side of picture)
Does anyone know where the error could be or has anyone ever had such an error message? Thanks a lot for your help!