taxlist (version 0.1.7)

backup_object: Make and load Backups of R Objects

Description

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.

Usage

backup_object(..., objects, file, stamp=TRUE, overwrite=FALSE)

load_last(file)

Arguments

...

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.

Value

An R image with extension *.rda.

Details

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.

See Also

save, load.

Examples

Run this code
# NOT RUN {
library(taxlist)
data(Easplist)

## A subset with Pseudognaphalium and relatives
Pseudognaphalium <- subset(Easplist, grepl("Pseudognaphalium", TaxonName),
	slot="names")
Pseudognaphalium <- get_parents(Easplist, Pseudognaphalium)

## Create a backup with date stamp
backup_object(Pseudognaphalium, file="Pseudonaphalium")

## The same
backup_object(objects="Pseudognaphalium", file="Pseudonaphalium")

## To load the last backup into a session
load_last("Pseudognaphalium")
# }

Run the code above in your browser using DataLab