Check if a vector follows R syntax rules
check_syntax.RdInternal helper function to verify whether values in a vector conform to R's variable naming rules.
Details
This function checks whether values in x comply with R's syntactic name rules using make.names().
A valid name consists of letters, numbers, dots (
.), or underscores (_).It must start with a letter or a dot not followed by a number.
See:
base::make.names()andbase::make.unique().
Examples
if (FALSE) { # \dontrun{
if (interactive()) {
check_syntax(c("C1", "C2", "T1", "T2")) # TRUE
check_syntax(c("C 100", "C-202", "T 303")) # FALSE
check_syntax(c("Var_1", "Var.2", ".Valid")) # TRUE
check_syntax(c(1, 2, 3, 4)) # TRUE (coerced to strings)
}
} # }