[R] Subseting data frame based on column names

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Mar 6 22:49:54 CET 2007



Li, Aiguo (NIH/NCI) [C] wrote:
> Hello all,
> 
>  
> 
> I have a data frame containing 170 columns and would like to generate a
> new data frame containing all rows but only 67 columns selected
> according to column names.  How can I do this?

For date.frame "d" and column names in vector "cn":

    d[,cn]

Uwe Ligges



>  
> 
> Thanks in advance,
> 
>  
> 
> AG Lee
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list