[R] "nonstandard" column names
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Jan 22 08:35:12 CET 2008
On Mon, 21 Jan 2008, Moshe Olshansky wrote:
> 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.
I would have thought 'the obvious thing' for $ was
x$`CPI/RPI`
which is how R prints non-syntactic names of lists. See
?Quotes
>
> 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.
>>
>
> ______________________________________________
> 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.
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list