Opening Rdata file on R

M.Raynaud picture M.Raynaud · Oct 8, 2018 · Viewed 9.7k times · Source

I have some trouble to open Rdata files on Rstudio.

I tried different directory.

I tried the load() function.

I set up the file pathway with 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()).

The file is 8.4 Mb (so not empty).

But it keeps saying:

"Object is not found"

It is downloaded from the internet but when I try load(url()) it says:

"cannot open the connection", however I do have internet connection. It also says "status was 'Couldn't connect to server' ".

Any thoughts ? Any ideas to solve the problem would be greatly appreciated.

Answer

Karolis Koncevičius picture Karolis Koncevičius · Oct 8, 2018

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
  2. Check if R sees that this file exists file.exists("C:/Downloads/thedata.RData")
  3. If this returns TRUE then the file is there. Try loading load("C:/Downloads/thedata.RData")
  4. Otherwise if file.exists() is FALSE then the file was not reachable. Try moving it to another place and try again

The error you get is Object not found. This error message doesn't seem to be used within the load() function. 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

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