View source: R/backup_object.R
backup_object | R Documentation |
When work with data becomes risky, the best practice is to produce backup
files.
The function of backup_object
is a wrapper of save()
, adding a
time stamp and a suffix to the name of the resulting file (an R image file
with extension *.rda).
The function load_last
is adapted to this style, loading the newest
version to the session.
backup_object(
...,
objects = character(),
file,
stamp = TRUE,
overwrite = FALSE
)
load_last(file, fext = ".rda")
... |
Names of the objects to be saved (either symbols or character strings). |
objects |
A character vector indicating the names of objects to be included in the backup file. |
file |
A character value indicating the name of the backup file, without the extension. |
stamp |
A logical value indicating whether time should be stamped in the backup name or not. |
overwrite |
A logical value indicating whether existing files must be overwritten or not. |
fext |
A character value indicating the file extension (including the dot symbol). |
In both functions the argument file
may include either the path
relative to the working directory or the absolute path to the file, excluding
stamps and extension.
For overwrite=FALSE
(the default), a numeric suffix will be added to
the backup's name, if another backup was produced at the same day.
For overwrite=TRUE
no suffix will be included in the file and existing
files will be overwritten.
The function load_last()
will load the newest version among backups
stored in the same folder, provided that the backup name includes a time
stamp.
An R image with extension *.rda.
Miguel Alvarez kamapu78@gmail.com
save
load
.
## A subset with Pseudognaphalium and relatives
Pseudognaphalium <- subset(x = Easplist, subset = grepl("Pseudognaphalium",
TaxonName), slot = "names", keep_parents = TRUE)
## Create a backup with date stamp in tempdir
backup_object(Pseudognaphalium, file = file.path(tempdir(), "Pseudonaphalium"))
## The same again
backup_object(Pseudognaphalium, file = file.path(tempdir(), "Pseudonaphalium"))
## Delete object
rm(list = "Pseudognaphalium")
## To load the last backup into a session
load_last(file = file.path(tempdir(), "Pseudonaphalium"))
## Load pre-installed backup
load_last(file.path(path.package("taxlist"), "extdata", "Podocarpus"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.