36

In recent efforts to develop a package, I'm including datasets in the data/ folder of my package. In my specific case I have 5 datasets all of which are in data.table format (although the issues I describe below persist if I keep them as data.frame). I've saved each one as individual .rda files and documented them appropriately.

When I run check() from package devtools, I get the following warnings:

 checking data for ASCII and uncompressed saves ... WARNING
  Warning: large data file(s) saved inefficiently:
          size ASCII compress
  data1.rda 129Kb  TRUE     gzip
  data2.rda 101Kb  TRUE     gzip
  data3.rda 1.6Mb  TRUE     gzip

  Note: significantly better compression could be obtained
        by using R CMD build --resave-data
              old_size new_size compress
  data1.rda         129Kb     34Kb       xz
  data2.rda         101Kb     20Kb       xz
  data4.rda          92Kb     35Kb       xz
  data3.rda         1.6Mb    116Kb       xz
  species.rda     12Kb      9Kb       xz

I've tried saving the data with resaveRdaFiles (package tools) with the recommended xz compression. Even after doing that, the warning persists.

OK, so I run R CMD build --resave-data and the warning continues to persist.

What am I missing here and how do I overcome this issue (now and in the future)?

Maiasaura
  • 32,226
  • 27
  • 104
  • 108
  • Could you try changing the compression options (see `compress` or `compression_level`) when you save the original RDA file? Perhaps resaveRdaFiles() does that properly? I'm not familiar with the function... – Jeff Allen Apr 19 '12 at 19:32
  • Did you try saveRDS (.rds file) instead...more info here http://ucfagls.wordpress.com/2012/04/01/saving-and-loading-r-objects/ – dickoa Apr 19 '12 at 21:37
  • Yep, tried `saveRDS()` and it does not save any space and you cannot run `resaveRdaFile()` on those to compress further. – Maiasaura Apr 19 '12 at 22:29
  • A package I wrote a couple of years back suddenly started producing this warning around when R 2.15 was being developed. In my case, the problem was that I'd made my .Rdata files back in version 2.9, and that format was deprecated. Manually re-saving the files with a recent R version seemed to do the trick. – David J. Harris Apr 20 '12 at 01:52

1 Answers1

33

When you save your .rda file, please use the command: save(..., file='test.rda', compress='xz') This will help to solve the problem!

eeerahul
  • 1,629
  • 4
  • 27
  • 38
heihei
  • 331
  • 2
  • 3
  • 3
    To (perhaps) clarify this point, I found something like `package.skeleton(name="mypackage")` followed by `save(test, file="mypackage/data/test.rda", compress='xz')` worked. – guyabel Jun 28 '12 at 11:35