save.var | R Documentation |
This function gets a list of variables as a character vector and save each variable name in a separate file, so that they can be loaded separately.
save.var(varlist = ls(envir = as.environment(.GlobalEnv)),
path = getwd(), newdir = TRUE, newdirtag = NULL, envir = .GlobalEnv)
varlist |
Character vector containing variable names. If not provided the function will use all the variables of the environment. (Optional) |
path |
Path to folder that you want to save the files in. If not provided, the current working directory will be used. (Optional) |
newdir |
Logical vector of length 1 indicating whether you want to create a subdirectory to store your variable files in. This subdirectory will have the execution time (%Y%m%d-%H%M%S) as folder name in combination with a text tag ('newdirtag') if provided. (Optional) |
newdirtag |
Character string used in combination with 'newdir=TRUE' to tag the time based folder name with a custom name. If not provided no tag will be used and the folder name will just have the time format. (Optional) |
envir |
Character string providing target environment in R session. The default is the Global Environment. (Optional) |
This function is used for saving variables in batch into separate files in an organized way. This specifically comes handy when you generate many variables either dynamically or manually and you want to save them for later use and empty your memory. Saving variables in separate files help finding them as a file easier and faster and also reduces the loading time of the variable since you are also loading those that you want to use.
The save.var function has the feature to save the variables in subfolder to help user manage different version of same variable which are related to different runs.
Mehrad Mahmoudian
save.image
, save
# generate variables dynamically
lapply(letters, function(x){assign(x=x, value=rnorm(1), env=globalenv())})
## Not run:
# simple usage
save.var()
# specify a list of variables with tag
save.var(varlist=c("a","e","i","o","u"), newdirtag="just_vowels")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.