[R] use of "@" character in variable name
Rolf Turner
r.turner at auckland.ac.nz
Fri Mar 27 02:40:29 CET 2009
On 27/03/2009, at 2:04 PM, Mike Miller wrote:
> Importing data with a header row using read.delim, one variable
> should be
> named @5HTT but it is automatically renamed to X.5HTT, presumably
> because
> the "@" is either unacceptable or misunderstood. I've tried to
> find out
> what the rules are on variable names but have been unsuccessful.
> I'll bet
> someone here can tell me where to look. Maybe it's hidden away in
> here
> somewhere:
>
> http://cran.r-project.org/doc/manuals/R-data.pdf
I don't know if there is a comprehensive list of the rules governing
variable names but the ``@'' sign is used to access ``slots'' under
S4 classes and methods. See ?"@". So it is (like?) an operation/
operator
and hence is ruled out just like ``+5HTT'' would be. Reserved words
like
``break'' and ``while'' are also excluded. See fortune(18).
Another rule is that a variable name can't begin with a digit.
And it can't have white space in it.
There are probably other rules, but essentially anything *sensible*
as a variable name can be used as a variable name.
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
More information about the R-help
mailing list