简体   繁体   English

在R上打开Rdata文件

[英]Opening Rdata file on R

I have some trouble to open Rdata files on Rstudio. 我在Rstudio上打开Rdata文件时遇到了一些麻烦。

I tried different directory. 我尝试了其他目录。

I tried the load() function. 我尝试了load()函数。

I set up the file pathway with setwd() . 我使用setwd()设置了文件路径。

I made sure that the file pathway did not contain spaces or accent or particular character in it. 我确保文件路径中不包含空格,重音符号或特定字符。

I tried the function load(file.choose()) . 我尝试了功能load(file.choose())

The file is 8.4 Mb (so not empty). 该文件为8.4 Mb(因此不能为空)。

But it keeps saying: 但它一直在说:

"Object is not found" “找不到对象”

It is downloaded from the internet but when I try load(url()) it says: 它是从Internet下载的,但是当我尝试load(url())它说:

"cannot open the connection", however I do have internet connection. “无法打开连接”,但是我确实有Internet连接。 It also says "status was 'Couldn't connect to server' ". 它还说“状态为'无法连接到服务器'”。

Any thoughts ? 有什么想法吗 ? Any ideas to solve the problem would be greatly appreciated. 解决问题的任何想法将不胜感激。

Try using the full path to locate the file. 尝试使用完整路径查找文件。

  1. Locate the file on your computer. 在您的计算机上找到文件。 Let's assume the location is C:/Downloads/thedata.RData 假设位置为C:/Downloads/thedata.RData
  2. Check if R sees that this file exists file.exists("C:/Downloads/thedata.RData") 检查R是否看到此文件存在file.exists("C:/Downloads/thedata.RData")
  3. If this returns TRUE then the file is there. 如果返回TRUE,则文件在那里。 Try loading load("C:/Downloads/thedata.RData") 尝试加载load("C:/Downloads/thedata.RData")
  4. Otherwise if file.exists() is FALSE then the file was not reachable. 否则,如果file.exists()为FALSE,则该文件不可访问。 Try moving it to another place and try again 尝试将其移至其他地方,然后重试

The error you get is Object not found . 您得到的错误是Object not found This error message doesn't seem to be used within the load() function. load()函数中似乎未使用此错误消息。 It can occur if the file-path is missing the surrounding quotes. 如果文件路径缺少引号,则会发生这种情况。

Maybe you forgot to quote the filename? 也许您忘了引用文件名了?

> load(myfile.RData)

Error in load(myfile.RData) : object 'myfile.RData' not found 加载错误(myfile.RData):找不到对象'myfile.RData'

> load("myfile.RData")
# Works without error.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM