Apply not finding an object created inside a function
Hi @nmanubens, With the new release, a simple function that was previously working fails. Here is the function and reproduction of the error:
library(multiApply)
#create input
forecast<-array(dim=c('31','12','4'),rnorm(31*12*4))
names(dim(forecast))<-c('sday','syear','ensemble')
anomaly_simple<-function(data){
avg<-Apply(data,c('syear','ensemble'),mean)[[1]]
anom<-Apply(data,c('sday'),function(x) x-avg)[[1]]
return(anom)
}
anomaly<-anomaly_simple(forecast)
I get the following error: Error in (function (x) : object 'avg' not found
If I try line by line, it works and with previous versions of multiApply also worked