[英]R-Studio cannot read .txt file
I have a problem that I cannot solve, and it is the following: I am writing a document with R-Studio, but every time I try to run it, the program says to me that there is an error. 我有一个无法解决的问题,原因如下:我正在用R-Studio编写文档,但是每次尝试运行它时,程序都对我说有错误。 The error apparently looks like to be linked to the fact that R studio is not able to load a table from a .txt file.
该错误似乎与R studio无法从.txt文件加载表这一事实有关。
This is what I have done: 这是我所做的:
setwd()
command) in the folder where the .txt file from which I want to source the table is located; setwd()
表格来源的.txt文件所在的文件夹中设置了工作目录(使用setwd()
命令); R-Studio gave me the following error: R-Studio给我以下错误:
Errore in eval(expr, envir, enclos) : oggetto "mydata" non trovato; eval(expr,envir,enclos)中的错误:oggetto“ mydata”非trovato; Calls: ... handle -> withCallingHandlers -> withVisible -> eval -> eval
调用:...处理-> withCallingHandlers-> withVisible-> eval-> eval
How can I solve this? 我该如何解决? I cannot figure out why R-Studio is not able to read the table and load the
data.frame
, while the Console inside R-Studio is. 我无法弄清楚为什么R-Studio无法读取表并加载
data.frame
,而R-Studio内部的控制台却无法。
Thank you for any help you can provide. 感谢您提供任何帮助。
When you knit a document in R-Studio, this happens in a separate environment. 在R-Studio中编织文档时,这是在单独的环境中发生的。 This means that variables that are available while you type in the console are not available when you knit a document.
这意味着编织文档时,在控制台中键入时可用的变量不可用。 Similarly, when you set the working directory in the console, this has no effect on knitting a document.
同样,在控制台中设置工作目录时,这对编织文档没有影响。
So the solution to your problem could be to simply add the setwd()
command to your .Rmd file. 因此,解决问题的方法可能是简单地将
setwd()
命令添加到.Rmd文件中。
在您的R Markdown文件中,您必须指定相对于Rmd
文件位置的txt
文件的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.