Call object from function environment in R -
i have function similar one:
function.mean.prod<-function(my.df,my.title){ tmp.df<-data.frame(year=1901:2099,productivity=na) for(i in 1:199)tmp.df[i,2]<-mean(my.df[,,i],na.rm=t) ggplot(tmp.df)+ geom_line(aes(tmp.df$year,tmp.df$productivity))+ ylab("productivity in g/c/qm")+ xlab("year")+ ggtitle(my.title) }
executing get:
error in eval(expr, envir, enclos) : object 'tmp.df' not found
so interpretation of error message object tmp.df
created temporarly inside functions environment , when functions executes loop can't call object.
is correct? how can set environment function able call inside loop? many thanks.
Comments
Post a Comment