[Rd] Syntactically valid names

Hadley Wickham hadley at rice.edu
Thu Jun 30 22:37:57 CEST 2011


Hi all,

Is there any easy way to tell if a string is a syntactically valid name?

e.g.

is.syntactic("X123")
# TRUE
is.syntactic("[[")
# FALSE

One implementation would be:

is.syntactic <- function(x) x == make.names(x)

but I wonder if there's a more elegant way.

Thanks!

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-devel mailing list