set_tidy_names

0th

Percentile

Repair object names.

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().

Usage
set_tidy_names(x, syntactic = FALSE, quiet = FALSE)

tidy_names(name, syntactic = FALSE, quiet = FALSE)

repair_names(x, prefix = "V", sep = "")

Arguments
x

A named vector.

syntactic

Should all names be made syntactically valid via make.names()?

quiet

If TRUE suppresses output from this function

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.

Value

x with valid names.

Aliases
  • set_tidy_names
  • tidy_names
  • repair_names
Examples
# NOT RUN {
# 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)
# }
Documentation reproduced from package tibble, version 1.3.4, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.