[R] Selecting columns of a table (not consecutive)
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Oct 3 08:10:01 CEST 2005
Nolwenn LeMeur <nlemeur at 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 at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list