powered by
Given a name you want and a possible alternative, this function renames an object as you want or errs with an informative message.
nms_try_rename(x, want, try)
A named object.
String of length 1 giving the name you want the object to have.
String of length 1 giving the name the object might have.
nms
Other functions for developers: check_crucial_names(), extract_insensitive(), flag_if_group(), is_multiple(), rename_matches(), type_ensure()
check_crucial_names()
extract_insensitive()
flag_if_group()
is_multiple()
rename_matches()
type_ensure()
nms_try_rename(c(a = 1), "A", "a") nms_try_rename(data.frame(a = 1), "A", "a") # Passes nms_try_rename(c(a = 1, 1), "A", "a") if (FALSE) { # Errs # nms_try_rename(1, "A", "A") }
Run the code above in your browser using DataLab