track (version 1.1.9)

track.rename: Rename variables in a tracked environment

Description

Rename variables in a tracked environment

Usage

track.rename(old, new, pos = 1, envir = as.environment(pos), clobber = FALSE, verbose = TRUE)

Arguments

old
character vector of old names
new
character vector of new names (must be same length as 'old')
pos
The position on the search list of the tracked db. Can be numeric or the name as returned by search().
envir
The tracked environment.
clobber
Should existing variables be overwritten?
verbose
Write out what is being done?

Value

A list containing the old and new names: A list containing the old and new names:

Details

Variables retain their tracked/untracked status (with the exception that a tracked variable can go from being tracked to being untracked if the new name matches the tracking option autoTrackExcludePattern.)

Renaming works correctly when old and new names overlap, e.g., track.rename(c("x","y"), c("y","x")) will swap the values of x and y.

Examples

Run this code
##############################################################
# Warning: running this example will cause variables currently
# in the R global environment to be written to .RData files
# in a tracking database on the filesystem under R's temporary
# directory, and will cause the variables to be removed temporarily
# from the R global environment.
# It is recommended to run this example with a fresh R session
# with no important variables in the global environment.
##############################################################

track.start(dir=file.path(tempdir(), 'rdatadir8'))
a <- 1
b <- rep(2, 2)
track.rename(c("a", "b"), c("b", "a"), clobber=TRUE)
c(a, b)
# Would normally not call track.stop(), but do so here to clean up after
# running this example.
track.stop(keepVars=TRUE)

Run the code above in your browser using DataLab