Commit a44018ab authored by Chris Holbrook's avatar Chris Holbrook

add compression (bzip2) to add_internal_data and resave objects in sysdata.rda...

add compression (bzip2) to add_internal_data and resave objects in sysdata.rda that were saved with version 2
parent 982d7ffd
No preview for this file type
......@@ -3,10 +3,15 @@
#--------------------------------------------------------------------------
#Add an internal data object to sysdata.rda
add_internal_data <- function(x, rda_file) {
e <- new.env()
load(rda_file, e) #load existing internals to new envir
assign(deparse(substitute(x)), x, envir = e) #add/replace with new object
save(list = ls(e), file = rda_file, envir = e, version = 2)
if(file.exists(rda_file)){
e <- new.env()
load(rda_file, e) #load existing internals to new envir
assign(deparse(substitute(x)), x, envir = e) #add/replace with new object
save(list = ls(e), file = rda_file, envir = e, compress = "bzip2",
version = 2)
} else {
usethis::use_data(x, internal = TRUE, version = 2)
}
}
#--------------------------------------------------------------------------
......@@ -15,5 +20,15 @@ remove_internal_data <- function(x, rda_file) {
e <- new.env()
load(rda_file, e) #load existing internals to new envir
rm(list = deparse(substitute(x)), envir = e) #remove unwanted object
save(list = ls(e), file = rda_file, envir = e, version = 2)
save(list = ls(e), file = rda_file, envir = e, compress = "bzip2",
version = 2)
}
#--------------------------------------------------------------------------
#Rebuild all internal data objects in sysdata.rda with all objects
#defined in data-raw
rebuild_internal_data <- function(rda_file = "R/sysdata.rda"){
data_raw_files <- list.files("./data-raw", full.names = TRUE)
sapply(data_raw_files, source)
return()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment