Search code examples
rrda

R CMD check and .RDa Data files


I have data files in the .RDa format under the data sub directory. But, the R CMD check command is not recognizing the load("test.RDa") command and its failing at this stage and gives the following error:

Warning in readChar(con, 5L, useBytes = TRUE) :  
cannot open compressed file 'test.RDa', probable reason 'No such file or directory'  
Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection  
Calls: load -> readChar  
Execution halted  

Can you please let me know the reason? Should I give a path specifying from where to load?


Solution

  • If you want to include data in your package, put it in mypkg/data/foo.rda and "load" it via data(foo). You should also create a mypkg/man/foo.Rd file to document the data.

    Read more in the Data in packages section of Writing R Extensions.