get_new_tmp_var | R Documentation |
Get a New Temporary Variable Name for a Dataset
get_new_tmp_var(dataset, prefix = "tmp_var")
dataset |
The input dataset
|
prefix |
The prefix of the new temporary variable name to create
|
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
.
The name of a new temporary variable as a symbol
remove_tmp_vars()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.