Re: [R] Selecting columns of a table (not consecutive)

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Mon 03 Oct 2005 - 16:10:01 EST

Nolwenn LeMeur <nlemeur@fhcrc.org> writes:

> George Papayiannis wrote:
>
> >Hi everyone,
> >
> >I have a table with 10 columns and many rows.
> >I want to select the 3rd,4th and 10th column.
> >
> >If I wanted to select the 3rd and 4th it would be no
> >problem.
> >
> >q3[ ,(3:4)]
> >
> >but how do I select the 10th along with it?
> >

> Try
> subset(q3, select=c(3,4,10))

Yes, but q3[,c(3:4,10)] works too. Notice that the index can be an arbitrary numeric vector.

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Mon Oct 03 16:12:20 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:09:31 EST