| set_tidy_names {tibble} | R Documentation |
tidy_names() ensures its input has non-missing and
unique names (duplicated names get a suffix of the format ..#
where # is the position in the vector).
Valid names are left unchanged, with the exception that existing suffixes
are reorganized.
tidy_names() is the workhorse behind set_tidy_names(), it treats the
argument as a string to be used to name a data frame or a vector.
repair_names() is an older version with different renaming heuristics,
kept for backward compatibility. New code should prefer tidy_names().
set_tidy_names(x, syntactic = FALSE, quiet = FALSE) tidy_names(name, syntactic = FALSE, quiet = FALSE) repair_names(x, prefix = "V", sep = "")
x |
A named vector. |
syntactic |
Should all names be made syntactically valid via |
quiet |
If |
name |
A character vector representing names. |
prefix |
A string, the prefix to use for new column names. |
sep |
A string inserted between the column name and de-duplicating number. |
x with valid names.
# Works for lists and vectors, too:
set_tidy_names(3:5)
set_tidy_names(list(3, 4, 5))
# Clean data frames are left unchanged:
set_tidy_names(mtcars)
# By default, all rename operations are printed to the console:
tbl <- as_tibble(structure(list(3, 4, 5), class = "data.frame"),
validate = FALSE)
set_tidy_names(tbl)
# Optionally, names can be made syntactic:
tidy_names("a b", syntactic = TRUE)