1

I built a custom R package a while back that has served me well. And now I have a dataset that is configured that I have used across multiple projects. I put the script sample_pop.R into /R in my package and ran it successfully to save RData df to the /data directory.

When I went to re-build I got the following error:

Warning: file 'sample_pop.RData' has magic number 'X' Use of save versions prior to 2 is deprecated
Error in load(zfile, envir = envir) : 
  bad restore file magic number (file may be corrupted) -- no data loaded

Is this the right way to add data to an R package such that I can access my own data like I access diamonds via ggplot library?

library(ggplot2)
diamonds %>% head()
UninformedUser
  • 8,397
  • 1
  • 14
  • 23
Jebediah15
  • 754
  • 3
  • 18
  • 39
  • 1
    Take a look at this: https://stackoverflow.com/questions/12463583/the-cause-of-bad-magic-number-error-when-loading-a-workspace-and-how-to-avoid and this https://stackoverflow.com/questions/16437349/bad-restore-file-magic-number-error-in-r?noredirect=1&lq=1 Do you have a link or snippet of code used to make the data set? – NelsonGon Jul 03 '19 at 17:29
  • Stupidly forgot I switched from saveRds and should have been using save() – Jebediah15 Jul 03 '19 at 17:34
  • Is it safe to mark it as a duplicate then so future users can find it? – NelsonGon Jul 03 '19 at 17:34
  • I was going to delete question? – Jebediah15 Jul 03 '19 at 17:35
  • 1
    I think you can leave it since it talks about package data(unique scenario, useful). – NelsonGon Jul 03 '19 at 17:36

0 Answers0