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
ada > > > > -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 > > > > Dear All, > > > > I have a quest

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 datafr

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

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

2013-10-04 Thread Jie
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 column by X[,'xi']. But it seems the single quote and double quote are different. So if I run X[, names(X)[i]], it has some error. Please use the below example code