例:在函数内部为全局变量赋值
all_predata_time <- data.frame(pd=0.1,Row=1,preRow=0,pt=0.1,stasid='1',InitDate='1');all_predata_time <- all_predata_time[-1,]......stasPowerPre_Time <- function(sid){ ...... pred <- forecast(x,h=365) predata <- data.frame(pd = as.double(pred$mean)) predata$Row <-as.integer(row.names(predata)); predata$preRow <- predata$Row -1; predata$pt <- as.double(c(0)); predata$stasid <- staid; predata$InitDate <- maxDate ; all_predata_time <<- rbind(all_predata_time,predata)}apply(stasList, 1, stasPowerPre_Time)