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

2009-03-27 Thread Gabor Grothendieck
Its possible to have otherwise illegal names by surrounding them
in backticks:

> `...@b` <- 3
> `...@b`
[1] 3

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

Also note use of check.names=FALSE:

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


On Thu, Mar 26, 2009 at 9: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
>
> Thanks in advance.
>
> Mike
>
> __
> R-help@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.
>

__
R-help@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.


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

2009-03-27 Thread Taylor, Z Todd
Camel case will cause database issues, too, at least if you ever
need to move from one db to another--every one seems to have its
own idea whether to preserve case, up-case, or down-case object
names.  You may not care if you only use one db and only from R.

SomeOfUsFindCamelCaseUnreadableToo.

--Todd
-- 
Why is a Guinea pig neither a pig nor from Guinea?


> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Krzysztof 
> Sakrejda-Leavitt
> Sent: Thursday, March 26, 2009 6:32 PM
> To: Mike Miller
> Cc: R-Help List
> Subject: Re: [R] use of "@" character in variable name
> 
> The '@' character is an operator used for accessing slots in 
> S4 classes. 
>   Similarly the '$' character is the operator for accessing 
> elements of 
> lists, etc...
> 
> Although R allows periods, SQL databases will choke on them.  
> LaTeX will 
> (sometimes?) choke on underscores, and of course any native R 
> operator 
> will cause problems.  My take is that camelBackCapitalization is the 
> best practice in naming columns, list elements, variables, 
> and functions 
> for R.
> 
> Best,
> 
> Krzysztof.
> 
> 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
> > 
> > Thanks in advance.
> > 
> > Mike
> > 
> > __
> > R-help@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.
> > 
> 
> -- 
> 
> ---
> Krzysztof Sakrejda-Leavitt
> 
> Organismic and Evolutionary Biology
> University of Massachusetts, Amherst
> 319 Morrill Science Center South
> 611 N. Pleasant Street
> Amherst, MA 01003
> 
> work #: 413-325-6555
> email: sakre...@nsm.umass.edu
> 
> __
> R-help@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.
> 

__
R-help@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.


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

2009-03-27 Thread Thomas Lumley

On Thu, 26 Mar 2009, 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


It's hidden away in: FAQ 7.14 What are valid names?

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
R-help@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.


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

2009-03-26 Thread Rolf Turner


On 27/03/2009, at 2:52 PM, Marc Schwartz wrote:



On Mar 26, 2009, at 8:40 PM, Rolf Turner wrote:



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.



See ?make.names for more information, which is noted in the
description of the 'check.names' argument in the read.table() family
of functions.


It might also be useful to note that a list of reserved words can be  
found via


?Reserved

(as I found out from ??"reserved words").

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@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.


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

2009-03-26 Thread John Fox
Dear Mike,

As a slight simplification, a legal R name can start with a period (.),
upper- or lower-case letter (A-Z, a-z), and can contain periods, underscores
(_), letters, and numerals; depending upon the locale, some other characters
may also be allowed. This information *is* in the R manuals, though it might
not be that easy to locate: See section 10.3.2 of the R Language Definition
manual or 1.8 of the Introduction to R manual.

@ is used to access slots in an S4 object.

I hope this helps,
 John


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
> Behalf Of Mike Miller
> Sent: March-26-09 9:04 PM
> To: R-Help List
> Subject: [R] use of "@" character in variable name
> 
> 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@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.

__
R-help@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.


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

2009-03-26 Thread Marc Schwartz


On Mar 26, 2009, at 8:40 PM, Rolf Turner wrote:



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.



See ?make.names for more information, which is noted in the  
description of the 'check.names' argument in the read.table() family  
of functions.


HTH,

Marc Schwartz

__
R-help@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.


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

2009-03-26 Thread Rolf Turner


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}}

__
R-help@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.


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

2009-03-26 Thread Krzysztof Sakrejda-Leavitt
The '@' character is an operator used for accessing slots in S4 classes. 
 Similarly the '$' character is the operator for accessing elements of 
lists, etc...


Although R allows periods, SQL databases will choke on them.  LaTeX will 
(sometimes?) choke on underscores, and of course any native R operator 
will cause problems.  My take is that camelBackCapitalization is the 
best practice in naming columns, list elements, variables, and functions 
for R.


Best,

Krzysztof.

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

Thanks in advance.

Mike

__
R-help@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.



--

---
Krzysztof Sakrejda-Leavitt

Organismic and Evolutionary Biology
University of Massachusetts, Amherst
319 Morrill Science Center South
611 N. Pleasant Street
Amherst, MA 01003

work #: 413-325-6555
email: sakre...@nsm.umass.edu

__
R-help@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.


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

2009-03-26 Thread Mike Miller
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@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.