Learn R Programming

track (version 1.0-13)

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:
  • olda character vector of names
  • newa character vector of 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
invisible(if (file.exists("tmp21")) unlink("tmp21", recursive=TRUE))
track.start(dir="tmp21")
a <- 1
b <- rep(2, 2)
track.rename(c("a", "b"), c("b", "a"), clobber=TRUE)
c(a, b)
track.stop()
invisible(if (file.exists("tmp21")) unlink("tmp21", recursive=TRUE))

Run the code above in your browser using DataLab