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

2013-10-05 Thread peter dalgaard
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

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

2013-10-04 Thread Rolf Turner
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]? cheers, Rolf Turner __ R-help@r-project.org

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

2013-10-04 Thread Greg Snow
Is there ever a case that X[,names(X)[4]] would give a different result than X[,4]? Or is this just a case of the "the longest distance between any 2 points is a shortcut"? Well I guess if X has non-unique names then you might see a difference, but having a data frame with non-unique names and us

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

2013-10-04 Thread John Kane
X[,names(X)[4]] works fine for me. I had never thought of doing this. Neat idea. John Kane Kingston ON Canada > -Original Message- > From: jimmycl...@gmail.com > Sent: Fri, 4 Oct 2013 12:06:50 -0400 > To: r-help@r-project.org > Subject: [R] quote a column of a dataframe by its name >

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

2013-10-04 Thread Rui Barradas
Hello, I had no problems, and it shouldn't. What exactly do you mean by "not working"? Hope this helps, Rui Barradas Em 04-10-2013 17:06, Jie escreveu: Dear All, I have a question, suppose X is a dataframe, with column names as "x1", "x2", "x3", . And I would like to use the i-th colum

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

2013-10-04 Thread Jie
Sorry, this sample code seems to be OK. I will look into my original problem and update it soon. Best wishes, On Fri, Oct 4, 2013 at 12:06 PM, Jie wrote: > Dear All, > > I have a question, suppose X is a dataframe, with column names as > "x1", "x2", "x3", . And I would like to use the i-th