make_better_names: Make names nicer to work with

Description Usage Arguments Value See Also Examples

View source: R/convenience.r

Description

Make names nicer to work with

Usage

1

Arguments

x

A character vector of names

Value

A transformed version of those names

See Also

make.names() and tibble::tibble()'s .name_repair argument

Resulting names are guaranteed to be unique, and will almost certainly be syntactic.

Examples

1
2
3
4
5
6
7
8
make_better_names(c("Country", "GDP $M", "Coast.Length"))
#> [1] "country" "gdp_mn"  "coast_length"
# Note that the guarantee to make the names unique can lead to some surprises
# for example, "a_and_b" becomes "a_and_b_3" in this case:
make_better_names(c("a and b", "a-and-b", "a.and.b", "a_and_b"))
#> c("a_and_b", "a_and_b_1", "a_and_b_2", "a_and_b_3")
# Here's a way to have a bad time:
make_better_names(c("", "x", "X", "x_1"))

karldw/kdw.junk documentation built on Sept. 8, 2021, 9:30 p.m.