Sanitize vector input to names

toNames(x)

Arguments

x

Object.

Value

character.

Note

Names resulting from this function do not necessarily return valid, and will not be identical to output from make.names().

Updated 2019-10-21.

See also

  • assertive.base:::to_names().

  • https://stackoverflow.com/questions/26183735

Examples

## Non-character vectors are supported. toNames(1)
#> [1] "1.000000000000000e+00"
toNames(complex(1L))
#> [1] "0+0i"
toNames(NA)
#> [1] "NA"
toNames(TRUE)
#> [1] "TRUE"
## Doesn't use 'make.names()' to sanitize. toNames(c("sample-1", "hello world"))
#> [1] "sample-1" "hello world"