Eh? I think x$"CPI/RPI" does work. See below, with two other ways.
> m <- data.frame(x = 1:3, "CPI/RPI" = 4:6, check.names = FALSE) > m x CPI/RPI 1 1 4 2 2 5 3 3 6 > m$"CPI/RPI" ### works for me! [1] 4 5 6 > m[, "CPI/RPI"] [1] 4 5 6 > m[["CPI/RPI"]] [1] 4 5 6 Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Moshe Olshansky Sent: Tuesday, 22 January 2008 9:37 AM To: r-help@r-project.org Subject: [R] "nonstandard" column names 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@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.