[R] "nonstandard" column names

Moshe Olshansky m_olshansky at yahoo.com
Tue Jan 22 02:56:05 CET 2008


Thanks to all those who responded!

Now the obvious thing (putting the column name into
double quotes) works for me too. But it didn't work
yesterday! I have no explanation for this. 

Moshe.

--- Moshe Olshansky <m_olshansky at yahoo.com> wrote:

> Hi everyone,
> 
> I am sure that this question has been asked here
> some
> time ago but I do not remember the answer and was
> unable to find it in the archives...
> 
> Below is my question: suppose that I have a
> data.frame
> x and one of it's columns name is "CPI/RPI" (without
> quotation marks of course). How can I reference this
> column? Neither of x$CPI/RPI or x$"CPI/RPI" work. I
> certainly can do x[,which(colnames(x) == "CPI/RPI")]
> but there should be a nicer way to do this.
> 
> Thank you!
> 
> Moshe Olshansky.
> 
> ______________________________________________
> 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