Does the input object have syntactically valid names?
Source:R/check-scalar-hasValidNames.R
check-scalar-hasValidNames.Rd
Does the input object have syntactically valid names?
Examples
## TRUE ====
x <- list("a" = 1L, "b" = 2L)
print(names(x))
#> [1] "a" "b"
print(hasValidNames(x))
#> [1] TRUE
x <- datasets::iris
print(hasValidDimnames(x))
#> [1] TRUE
## FALSE ====
x <- list(
"1" = 1, # can't start with number
"foo bar" = 2, # no spaces
"foo-bar" = 3 # no hyphens
)
print(x)
#> $`1`
#> [1] 1
#>
#> $`foo bar`
#> [1] 2
#>
#> $`foo-bar`
#> [1] 3
#>
print(hasValidNames(x))
#> [1] FALSE
x <- datasets::mtcars
print(hasValidDimnames(x))
#> [1] FALSE