0

I built an R package containing data with devtools (https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/). I put the data in R/sysdata.rda because data are just used by my functions :

use_data(mydf1, mydf2, mydf3, internal = TRUE)
use_data_raw()

I need very fast functions, thus I wrote LazyData: false in the DESCRIPTION file. When I first used my function of the package I got :

library(myPackage)
system.time(myFunction(...))
user  system elapsed 
1.53    0.11    1.66

However when I secondly used the same function with the same inputs I got :

system.time(myFunction(...))
user  system elapsed 
0.05    0.00    0.04

Thus, I guess my internal data were lazy loaded. I also guess that LazyData: false in the DESCRIPTION file is only relative to data in ./data not to internal data (R/sysdata.rda) :

1) Am I correct ?

2) If yes, how can I make internal data not lazy data ?

The 2 following subjects do not answer this issue :

Automatic loading of data from sysdata.rda in package

How do you handle R Data internal to a package?

Community
  • 1
  • 1
JPL
  • 267
  • 4
  • 11
  • 2
    Just as a note: making data loading non-lazy won’t actually make your function faster. The performance hit just occurs at a different moment (always, and at the beginning, rather than later and as needed). So making data loading eager serves to make runtime more predictable, but *not faster*. – Konrad Rudolph Dec 21 '16 at 18:36
  • Thanks for your comment. In fact, I just need to get the result as quickly as possible from the first run of my function using internal data after having call the package. Understand the mechanism of the data loading in this situation is not so obvious. – JPL Dec 22 '16 at 08:15

0 Answers0