Opening Rdata file on R

11,833

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.
Share:
11,833
M.Raynaud
Author by

M.Raynaud

Updated on December 07, 2022

Comments

  • M.Raynaud
    M.Raynaud over 1 year

    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.

  • M.Raynaud
    M.Raynaud over 5 years
    Thank you for your clear answer. I tried your function. Actually is says TRUE, so the file is detected but when I afterwards run the load function, it keeps saying "object is not found". I tried anyhow another place and it is not working.
  • Karolis Koncevičius
    Karolis Koncevičius over 5 years
    You said that the file is downloaded from the internet. Can you provide an URL, or is it private?
  • Karolis Koncevičius
    Karolis Koncevičius over 5 years
    Also expanded the answer about your error - maybe you forgot to quote the filename? (put it inside " ")
  • M.Raynaud
    M.Raynaud over 5 years
    Yes the URL is private, sorry. I actually did not forget to use the quotes.
  • Karolis Koncevičius
    Karolis Koncevičius over 5 years
    In that case can you show us the full error message you get?
  • M.Raynaud
    M.Raynaud over 5 years
    > Error in load(url("------/mod_europe_un_beta_g9.Rdata")) : cannot open the connection to '------/mod_europe_un_beta_g9.Rdata' De plus : Warning message: In load(url("------/mod_europe_un_beta_g9.Rdata")) : URL '------/mod_europe_un_beta_g9.Rdata': status was 'Couldn't connect to server'
  • Karolis Koncevičius
    Karolis Koncevičius over 5 years
    This is the error you should be getting when using url. What about the error when trying to load the downloaded file?
  • M.Raynaud
    M.Raynaud over 5 years
    Oh sorry. there's no error when I run the load function. But when I run the object, it says "Object 'mod_europe_un_beta_g9' is not found"
  • Karolis Koncevičius
    Karolis Koncevičius over 5 years
    After loading the data do ls() to see what objects are available. Maybe you are trying to use an object that was not in the file.
  • M.Raynaud
    M.Raynaud over 5 years
    Okay I understood the problem. The object I tried to open was supposed to be the result of a model (a highly consuming model that a guy ran for me). But the guy kept the name of the model and actually gave several file (database, vector, result of the model, function...) so I was trying to read an environment. Thank you for ls() function Karolis, you helped me a lot !