我正在运行以下代码...
#Create a list of all the files
file.list <- list.files(path="~/R/natural-language-processing/class-notes", pattern=".csv")
#Loop over file list importing them and binding them together
D1 <- do.call("rbind",lapply(file.list, read.csv, header = TRUE, stringsAsFactors = FALSE))
这是我运行时遇到的错误do.call
上面的线。
文件错误(文件,“rt”):无法打开连接
我已经尝试重置我的 wd.我现在的getwd()
is
~/R/natural-language-processing
我已经看过其他的了
文件错误(文件,“rt”):无法打开连接
您很可能正在尝试从工作目录而不是您调用的目录中打开文件list.files
。相反尝试
D1 <- do.call("rbind",
lapply(paste0("~/R/natural-language-processing/class-notes/",
file.list),
read.csv, header = TRUE, stringsAsFactors = FALSE))
或者,您可以设置full.names
论证TRUE
in list.files
获取完整路径:
file.list <- list.files(path="~/R/natural-language-processing/class-notes",
pattern=".csv", full.names = TRUE)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)