Error in file(file, “rt“) : cannot open the connection In addition: Warning message:In file(file, “
Error in file(file, "rt") : cannot open the connection In addition: Warning message:
In file(file, "rt") : cannot open file 'data.csv': No such file or directory
目录
Error in file(file, "rt") : cannot open the connection In addition: Warning message:In file(file, "rt") : cannot open file 'data.csv': No such file or directory
问题:
解决:
完整错误:
问题:
#如果没有设置全局的目录直接读取文件就找不到目录
#attempt to read in CSV file
df <- read.csv('data.csv')
解决:
第一,使用绝对路径(完整路径)
df <- read.csv('C:\\Users\\test\\Desktop\\data.csv', header=TRUE, stringsAsFactors=FALSE)
第二,配置程序环境的全局指定目录:
#display current directory
getwd()
[1] "C:/Users/xxx/Documents"
#set current directory
setwd('C:\\Users\\test\\Desktop')
完整错误:
> #attempt to read in CSV file
> df <- read.csv('data.csv')
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'data.csv': No such file or directory
参考:R
参考:How to Fix: error in file(file, “rt”) : cannot open the connection
来源:Data+Science+Insight