track.rename: Rename variables in a tracked environment

Description Usage Arguments Details Value Author(s) Examples

View source: R/track.rename.R

Description

Rename variables in a tracked environment

Usage

1
2
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?

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.

Value

A list containing the old and new names:

old

a character vector of names

new

a character vector of names

Author(s)

Tony Plate tplate@acm.org

Examples

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

track documentation built on May 2, 2019, 10:22 a.m.