[R] choosing multiple columns
John Kane
jrkrideau at inbox.com
Sat Aug 11 14:43:38 CEST 2012
mydata[ , 1:8]
Or let's say you only one the 4th, 6th and 8th columns
mydata[ , c(4,6,8)]
and so on.
There are several good intro's available on the R website that will walk you through this type of thing.
If you're a recovering SAS or SPSS user this paper may be of real help www.et.bs.ehu.es/~etptupaf/pub/R/RforSAS&SPSSusers.pdf
John Kane
Kingston ON Canada
> -----Original Message-----
> From: sachin.abeywardana at gmail.com
> Sent: Sat, 11 Aug 2012 21:59:59 +1000
> To: r-help at r-project.org
> Subject: [R] choosing multiple columns
>
> 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,
> Sachin
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
More information about the R-help
mailing list