Re: [R] Column name containing "-"

2012-01-24 Thread Bert Gunter
Ivan: AFAICS you did not read my post carefully enough. Unquoted improper identifiers trigger an error because the input cannot be parsed. It has nothing to do with data.frame() .(**R EXPERTS, PLEASE CORRECT IF WRONG**). Unquoted LEGAL names are accepted because that's how R works -- they can be p

Re: [R] Column name containing "-"

2012-01-24 Thread R. Michael Weylandt
Sorry, I meant check.names = FALSE (d'oh!) Michael On Tue, Jan 24, 2012 at 11:33 AM, R. Michael Weylandt wrote: > I've usually understand the restrictions on syntactic names as being > tied to the parser. > > E.g., how could R tell the difference between > > d <- data.frame(a = 3, `a-2` = 3, che

Re: [R] Column name containing "-"

2012-01-24 Thread R. Michael Weylandt
I've usually understand the restrictions on syntactic names as being tied to the parser. E.g., how could R tell the difference between d <- data.frame(a = 3, `a-2` = 3, check.names = TRUE) d$a-2 ## Equal to 1 or 3 ? One of those strange eval things that makes alot of sense for an interactive lan

Re: [R] Column name containing "-"

2012-01-24 Thread Ivan Calandra
Bert, Thank you for correcting my inaccuracy. A quick look at the original question might help you understand what I meant: d<- data.frame(x = c(0, 1)) d<- data.frame(d, y = c(0,1)) names(d)[2]<- "a.-5" d x a.-5 1 00 2 11 d1<- data.frame(d, y = c(0,1)) d1 x a..5 y 1 00 0 2 11

Re: [R] Column name containing "-"

2012-01-24 Thread Bert Gunter
Ivan: On Tue, Jan 24, 2012 at 6:47 AM, Ivan Calandra wrote: > By "it works anyway", I mean that you can have a dash in a column name, > there is no error or even warning. > I guess that some functions would throw an error or warning, depending on > the requirements, but data.frame() doesn't. Thi

Re: [R] Column name containing "-"

2012-01-24 Thread Ivan Calandra
By "it works anyway", I mean that you can have a dash in a column name, there is no error or even warning. I guess that some functions would throw an error or warning, depending on the requirements, but data.frame() doesn't. Ivan Le 24/01/12 15:35, David Winsemius a écrit : On Jan 24, 2012,

Re: [R] Column name containing "-"

2012-01-24 Thread David Winsemius
uot;valid" since it works anyway. The dash is not a valid character for column names. What do you mean by "it works anyway"? -- David. You can set up the check.names argument to FALSE when you call data.frame(). HTH, Ivan ---- Message original ---- Sujet: [R] Column

Re: [R] Column name containing "-"

2012-01-24 Thread Ivan Calandra
check.names argument to FALSE when you call data.frame(). HTH, Ivan Message original ---- Sujet: [R] Column name containing "-" Date : Tue, 24 Jan 2012 20:34:07 +1100 De :Mark Seeto Pour : r-help@r-project.org I'm trying to create a data frame in which some of

[R] Column name containing "-"

2012-01-24 Thread Mark Seeto
I'm trying to create a data frame in which some of the column names contain a dash "-". A simple example: d <- data.frame(x = c(0, 1)) d <- data.frame(d, y = c(0,1)) names(d)[2] <- "a.-5" d x a.-5 1 00 2 11 d <- data.frame(d, y = c(0,1)) d x a..5 y 1 00 0 2 11 1 names(d)[2] <