[R] quote a column of a dataframe by its name

peter dalgaard pdalgd at gmail.com
Sat Oct 5 09:18:27 CEST 2013

On Oct 5, 2013, at 00:47 , Rolf Turner wrote:

> On 10/05/13 05:15, John Kane wrote:
>> X[,names(X)[4]]  works fine  for me.  I had never thought of doing this. Neat idea.
> Perhaps I am being obtuse, but how would X[,names(X)[4]] differ from X[,4]?

By answering the question in the Subject field?

(No-one intended to use it in production code. The mystery is that it - reportedly - threw an error for the original poster, but not for anyone else.)


Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com

More information about the R-help mailing list