tempvar | R Documentation |
Gets a unique non-existing temporary variable name, and optionally assigns it an initial value.
tempvar(prefix="var", value, envir=parent.frame(), inherits=FALSE)
prefix |
A |
value |
(optional) If given, a variable with the temporary
name is assigned this value. Only works if |
envir |
An |
inherits |
A |
Returns a character
string.
Henrik Bengtsson
tempfile
() and assign
().
# 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)
# Get a temporary variable for a data.frame
name <- tempvar(envir = datasets::mtcars)
print(name)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.