我编写了以下函数来组合300个.csv文件.我的目录名是"specdata".我已经完成了以下执行步骤,
x <- function(directory) {
dir <- directory
data_dir <- paste(getwd(),dir,sep = "/")
files <- list.files(data_dir,pattern = '\\.csv')
tables <- lapply(paste(data_dir,files,sep = "/"), read.csv, header = TRUE)
pollutantmean <- do.call(rbind , tables)
}
# Step 2: call the function
x("specdata")
# Step 3: inspect results
head(pollutantmean)
Error in head(pollutantmean) : object 'pollutantmean' not found
Run Code Online (Sandbox Code Playgroud)
我的错是什么?有人可以解释一下吗?