Re: [R] extract columns from a dataframe

From: Yves Magliulo <ym_at_climpact.com>
Date: Mon 05 Jul 2004 - 23:49:15 EST

hi,

see colnames()
simple use, good result.

ex: if df is your data.frame and toto = the column name you want to extract do:

df2<-df[,colnames(df)==toto)] #extract all toto column

Le lun 05/07/2004 à 14:53, Rado Bonk a écrit :
> Dear R users,
>
> I'm coming back to R after while. I have a data frame with 200 columns,
> each column has a name. How to extract all columns to a new dataset, but
> the specified (by names) ones?
>
> I was playing with that for a little bit using the vector syntax but got
> several syntax errors.
>
>
> Thanks,
>
> Rado
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
------
Yves Magliulo <ym@climpact.com>
Climatology research department, CLIMPACT

Tel.   : +33 (0) 1 55 07 85 77
Fax.   : +33 (0) 1 55 07 85 79
Universite Pierre et Marie Curie
Boite 101 - Tour 45 - 5eme etage - Couloir 45/46
4 place Jussieu, 75252 Paris CEDEX 05, France

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Mon Jul 05 23:53:37 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:33:14 EST