pollutantmean <- function(directory, pollutant, id = 1:332) {
for(i in id) {
filenames <- list.files(path = directory, pattern = ".csv", full.names = TRUE);
pollutant_data <- NULL;
for (f in filenames){
fdata <- read.csv(f, header=TRUE);
pollutant_data <- c(pollutant_data,fdata$pollutant);
}
poll_mean <- mean(pollutant_data, na.rm=TRUE);
return(poll_mean);
}
}
source("pollutantmean.R");
当我运行上面显示的代码时,我收到以下错误消息.... sys.call(sys.parent())出错:节点堆栈溢出 换行时出错:节点堆栈溢出
为什么我会看到此错误,如何避免错误? 谢谢!