[R] use of "@" character in variable name

Gabor Grothendieck ggrothendieck at gmail.com
Sat Mar 28 00:43:48 CET 2009


Its possible to have otherwise illegal names by surrounding them
in backticks:

> `a at b` <- 3
> `a at b`
[1] 3

> `if` <- 55
> `if`
[1] 55

Also note use of check.names=FALSE:

> Lines <- "a at b if
+ 1 2"
> DF <- read.delim(textConnection(Lines), header = TRUE, check.names = FALSE)
> DF
  a at b if
1    1 2


On Thu, Mar 26, 2009 at 9:04 PM, Mike Miller <mbmiller+l at gmail.com> 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
>
> Thanks in advance.
>
> Mike
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list