get_new_tmp_var {admiraldev} | R Documentation |
Get a New Temporary Variable Name for a Dataset
Description
Get a New Temporary Variable Name for a Dataset
Usage
get_new_tmp_var(dataset, prefix = "tmp_var")
Arguments
dataset |
The input dataset |
prefix |
The prefix of the new temporary variable name to create |
Details
The function returns a new unique temporary variable name to be used inside
dataset
. The temporary variable names have the structure prefix_n
where
n
is an integer, e.g. tmp_var_1
. If there is already a variable inside
datset
with a given prefix
then the suffix is increased by 1, e.g. if
tmp_var_1
already exists then get_new_tmp_var()
will return tmp_var_2
.
Value
The name of a new temporary variable as a symbol
See Also
Examples
library(dplyr, warn.conflicts = FALSE)
dm <- tribble(
~DOMAIN, ~STUDYID, ~USUBJID,
"DM", "STUDY X", "01-701-1015",
"DM", "STUDY X", "01-701-1016",
)
tmp_var <- get_new_tmp_var(dm)
mutate(dm, !!tmp_var := NA)
[Package admiraldev version 1.1.0 Index]