rename_from | R Documentation |
Renames the elements of a vector or list from a dictionary, leaving unmatched names untouched by default.
rename_from(x, dict, default = names(x))
x |
Object whose elements are to be renamed. |
dict |
A named character vector or list of strings where names are the old and the values are the new names. |
default |
Value(s) used when names aren't matched by any name in |
x
with elements renamed according to dict
.
mtcars |> pal::rename_from(dict = c(mpg = "Miles/(US) gallon",
cyl = "Number of cylinders",
disp = "Displacement (cu.in.)",
hp = "Gross horsepower",
drat = "Rear axle ratio",
wt = "Weight (1000 lbs)",
qsec = "1/4 mile time",
vs = "Engine (0 = V-shaped, 1 = straight)",
am = "Transmission (0 = automatic, 1 = manual)",
gear = "Number of forward gears",
carb = "Number of carburetors",
not_there = "Yikes!"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.