简体   繁体   中英

Troubleshooting in loading files in R

I'm brand new learner programming "R'.but faced problem in loading files:

I used this code :

getwd()
load("genData.RData")
genData

Output shows: Console:

> getwd()
[1] "C:/Users/User/Documents"
> load("genData.Rdata")
Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
  cannot open compressed file 'genData.Rdata', probable reason 'No such file or directory'
> genData
Error: object 'genData' not found

Is there any kind sould to unravel the problem??

Thanks in advance.

This error appears because R cannot find the file in the current working directory (the working directory is the one you see with the command getwd()). This can either be because your file is in another directory (if so, try specifying the full path, or change working directory to the one where the file is located with setwd()) or because the name of the file is wrong (check syntax). To see if the file is in the current working directory, you can also do

list.files(pattern='*.Rdata')

This prints out in the R console all the files contained in the current working directory which have an .Rdata extension. Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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