如何使用相对路径从工作目录加载.rdata文件?
我正在尝试使用load()
函数将.rdata文件加载到当前的R会话中。我通过双击目录中的R项目文件打开代码库,然后尝试通过运行load('./ data/mydata.rdata')
来加载.rdata文件。但是,这会返回“没有此类文件或目录”错误。我通过使用getwd()
验证了工作目录是正确的。
我认为我必须使用错误的语法,因为当我输入完整文件路径时,我没有加载文件的问题。
R项目文件的工作目录:“/users/me/librare/oneDrive/rstuff”
包含.rdata文件的目录:”/users/users/me/m i/library/oneedrive/rstuff /data“
有效的代码: load(“/users/me/me/library/oneedrive/rstuff/data/mydata.rdata”)
diff fife diff> 代码:< /strong> load('./ data/mydata.rdata')
相对路径是否与load()
或我的语法是错误的?
I am trying to use the load()
function to load an .RData file into my current R session. I open my code base by double clicking on the R project file in my directory and then attempt to load the .RData file by running load('./Data/mydata.rdata')
. However, this returns a 'No such file or directory' error. I verified that the working directory is correct by using getwd()
.
I figure I must be using incorrect syntax because I have no issues loading the file when I type in the full file path.
Working directory for R Project file: "/Users/Me/Library/OneDrive/RStuff"
Directory containing .RData file: "/Users/Me/Library/OneDrive/RStuff/Data"
Code that works: load("/Users/Me/Library/OneDrive/RStuff/Data/mydata.rdata")
Code that fails: load('./Data/mydata.rdata')
Do relative paths not work with load()
or is my syntax wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您的路径有错误。您说工作目录是
“/users/me/library/oneDrive/rstuff”
,但根据有效的代码:
...数据文件在
中“/users/me//库/oneDrive/rstuff/data“
为了使用相对路径,您将使用:
It looks like there is an error with your paths. You said the working directory is
"/Users/Me/Library/OneDrive/RStuff"
But according to the code that works:
...the data file is in
"/Users/Me/Library/OneDrive/RStuff/Data"
Therefore to use relative paths, you would use: