backup_object: Make and load Backups of R Objects

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/backup_object.R

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

1
2
3

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.

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.

Value

An R image with extension *.rda.

Author(s)

Miguel Alvarez, [email protected].

See Also

save, load.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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")

## End(Not run)

taxlist documentation built on July 2, 2018, 1:03 a.m.