rename_in | R Documentation |
Elements of x
whose names are in nm
will be renamed.
rename_in(x, nm, f, ...)
x |
An object with names. |
nm |
A character vector passed to |
f |
A function, one-sided formula, or character vector. |
... |
Passed into |
If f
is a function it will be applied to the selected names. If it is
a formula and the 'rlang' package is installed, it will be converted to a
function by rlang::as_function()
, then
applied.
If f
is a named character vector like c(new_name = "old_name", ...)
then
"old_name"
will become "new_name"
, as in dplyr::rename()
.
If f
is an unnamed character vector, these will be the new names in order.
The renamed object.
vec <- c("One" = 1, "Two" = 2, "Three" = 3, "Four" = 4)
vec |> rename_in(c("Two", "Three"), paste0, "x")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.