I am building an R package and using data-raw
and data
to store a library of pre-defined RxODE
models. This works very well.
However, the resulting .rda
files change at every generation. Some models contain an R environment, and the serialization seems to contain a 'creation time' timestamp. This means every time the data/
directory is regenerated, all files have changed...
Is there some way to modify the serialization of an R environment to be reproducible?
storeFile <- function(file) {
env <- new.env()
fun <- function(x) {x+3}
environment(fun) <- env
save('fun', file = file, ascii=TRUE)
}
storeFile('fileA.rda')
storeFile('fileB.rda')
message("Files are identical? ", identical(readLines('fileA.rda'), readLines('fileB.rda')) )