Re: [R] choosing multiple columns

2012-08-12 Thread David Winsemius
On Aug 11, 2012, at 6:01 AM, Ista Zahn wrote: On Sat, Aug 11, 2012 at 8:51 AM, Sachinthaka Abeywardana wrote: I should have mentioned that I do not know the number index of the columns, but regardless, thanks for the responses Right, so use my first method. This does not depend on the pos

Re: [R] choosing multiple columns

2012-08-11 Thread arun
27448 5.286831 5.521572 4.036457 5.532234 #5 5.500054 6.080370 6.259925 3.946102 4.554102 Hope this helps. A.K. - Original Message - From: Sachinthaka Abeywardana To: r-help@r-project.org Cc: Sent: Saturday, August 11, 2012 7:59 AM Subject: [R] choosing multiple columns Hi all, I hav

Re: [R] choosing multiple columns

2012-08-11 Thread Ista Zahn
On Sat, Aug 11, 2012 at 8:51 AM, Sachinthaka Abeywardana wrote: > I should have mentioned that I do not know the number index of the columns, > but regardless, thanks for the responses Right, so use my first method. This does not depend on the position of the columns. Best, Ista > > > On Sat, A

Re: [R] choosing multiple columns

2012-08-11 Thread Sachinthaka Abeywardana
I should have mentioned that I do not know the number index of the columns, but regardless, thanks for the responses On Sat, Aug 11, 2012 at 10:46 PM, Ista Zahn wrote: > Hi Sachin, > > There are at least two ways. The safer way is to use a regular > expression to find the matching columns, like

Re: [R] choosing multiple columns

2012-08-11 Thread Ista Zahn
Hi Sachin, There are at least two ways. The safer way is to use a regular expression to find the matching columns, like this: a <- initial_data[grep("^OFB[0-9]+", names(initial_data))] Alternatively, if you know that the columns you want are the first 8 you can select them by position, like this

Re: [R] choosing multiple columns

2012-08-11 Thread John Kane
be of real help www.et.bs.ehu.es/~etptupaf/pub/R/RforSAS&SPSSusers.pdf John Kane Kingston ON Canada > -Original Message- > From: sachin.abeyward...@gmail.com > Sent: Sat, 11 Aug 2012 21:59:59 +1000 > To: r-help@r-project.org > Subject: [R] choosing multiple columns > > H

[R] choosing multiple columns

2012-08-11 Thread Sachinthaka Abeywardana
Hi all, I have a data frame that has the columns OFB1, OFB2, OFB3,... OFB10. How do I select the first 8 columns efficiently without typing each and every one of them. i.e. I want something like: a<-data.frame(initial_data$OFB1-10) #i know this is wrong, what would be the correct syntax? Thanks