http://rstudio-pubs-static.s3.amazonaws.com/288810_5d573bbed5924cd0936ff74646afb688.html
题目是上面的链接,然后我就开始做,写了一串
mainDir <- "~/Users/JQ/Desktop"
subDir <- "specdata"
if (file.exists(subDir)){
setwd(file.path(mainDir, subDir)) }
else{
dir.create(file.path(mainDir, subDir))
setwd(file.path(mainDir, subDir))
}
pollutantmean <- function(specdata, pollutant, id = 1: 332){
for (i in id) {
MonitorsData <- read.csv(specdata[i])
PollutantData <- MonitorsData[pollutant]
means <- c(means, PollutantData[!is.na(PollutantData)])
}
mean(means)
}
但是每次都得到Error in setwd(file.path(mainDir, subDir)) : 无法改变工作目录;
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
no lines available in input
求大家看看问题出在了哪里