[英]Error in file(file, “rt”)
I'm using Rstudio and I cannot open several file .txt because of this error message : 我正在使用Rstudio,由于以下错误消息,我无法打开多个文件.txt:
Error in file(file, "rt") : cannot open the connection
I enter : 我输入:
X1= read.table("fileX1.txt", header = FALSE)
I don't understand because some of my colleagues use the same function with the same .txt
file and it works for them 我不明白,因为我的一些同事对相同的
.txt
文件使用相同的功能,并且对他们有用
Since you aren't specifying the path to the file, R will look for it in the current directory. 由于您没有指定文件的路径,因此R会在当前目录中查找它。 If that isn't the directory containing the file, you'll get that error.
如果那不是包含文件的目录,则将得到该错误。
You can use setwd()
(or a menu command in RStudio) to set the current directory. 您可以使用
setwd()
(或RStudio中的菜单命令)来设置当前目录。 Alternatively, you could use file.choose()
to get a dialog to choose the file; 另外,您可以使用
file.choose()
获得一个对话框来选择文件; it will return the full filename including the path. 它将返回完整的文件名,包括路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.