Description Usage Arguments Value Author(s) References See Also Examples
Make syntactically valid names out from character vectors replacing
.
(dot) with _
underscore. Hhis is useful when you wish
to use snake_case naming convention or are using SQL.
1 | make_names(names, unique = FALSE, leading_ = "")
|
names |
character; vector to be coerced to syntactically valid names. This is coerced to character if necessary. |
unique |
logical; if TRUE, the resulting elements are unique. This may be desired for, e.g., column names. |
leading_ |
What to replace leading '_' and '.' with. Can be only: A-Z, a-z, ., or "" (Defaults) Calls Multiple consecutive underscores are replaced by a single underscore. Names the end up with leading underscores are replaced with
This function is idempotent – multiple application of the function do not change the results. |
a character vector containing
Christopher Brown
https://en.wikipedia.org/wiki/Snake_case
http://titlecase.com
1 2 3 4 5 6 7 8 9 10 11 12 | make_names(c("foo and bar", "foo-and-bar"), unique = TRUE)
# "foo_and_bar" "foo_and_bar_1"
make_names(c("foo and bar", "foo.and_bar"), unique = FALSE)
# "foo.and.bar" "foo_and_bar"
make_names(c("foo and bar", "foo.and_bar"), unique = TRUE)
# "foo_and_bar" "foo_and_bar_1"
make_names( c(".foo", "_bar") ) # "foo" "bar"
make_names( c(".foo", "_bar"), leading="." ) # ".foo" ".bar"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.