From cubranic at stat.ubc.ca  Wed Jul  6 01:55:28 2011
From: cubranic at stat.ubc.ca (Davor Cubranic)
Date: Tue, 5 Jul 2011 16:55:28 -0700
Subject: [Rd] Syntactically valid names
In-Reply-To: <BANLkTimg=TM0hYA1=Obknb+486Hv8T7Fdw@mail.gmail.com>
References: <BANLkTimg=TM0hYA1=Obknb+486Hv8T7Fdw@mail.gmail.com>
Message-ID: <201107051655.28642.cubranic@stat.ubc.ca>

On June 30, 2011 01:37:57 PM Hadley Wickham wrote:

> Is there any easy way to tell if a string is a syntactically valid name?
[...]
> 
> One implementation would be:
> 
> is.syntactic <- function(x) x == make.names(x)
> 
> but I wonder if there's a more elegant way.

This is without quoting, right? Because "make.names" replaces spaces with 
periods, and using quoting I can create syntactically valid names that do 
include spaces:

    `x prime` <- 3
    ls()

Davor



[Rd] Syntactically valid names
Davor Cubranic