[R] "nonstandard" column names

Moshe Olshansky m_olshansky at yahoo.com
Tue Jan 22 00:36:46 CET 2008


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.



More information about the R-help mailing list