Last chance! 50% off unlimited learning
Sale ends in
Gets a unique non-existing temporary variable name and optionally assigns it an initial value.
tempvar(prefix="var", value, envir=parent.frame(), inherits=FALSE)
A character
string specifying the prefix of the
temporary variable name.
(optional) If given, a variable with the temporary name is assigned this value.
An environment
where the variable should exist.
A logical
specifying whether the enclosing frames
of the environment should be searched or not.
Returns a character
string.
# NOT RUN {
# Get a temporary variable
name <- tempvar()
print(name)
# Get and assign a temporary variable
name <- tempvar(value=base::letters)
print(name)
str(get(name))
# Get a temporary variable with custom prefix
name <- tempvar(prefix=".hidden")
print(name)
# }
Run the code above in your browser using DataLab