[R] Removing columns from data frame

Bill.Venables@cmis.csiro.au Bill.Venables at cmis.csiro.au
Tue Jul 23 00:55:37 CEST 2002


I'm not sure of precisely what you don't want to use (or why) but here is
one way

newDataFrame <- oldDataFrame[ , - match(namesToGo, names(oldDataFrame))]

Bill Venables

>  -----Original Message-----
> From: 	Daniel Mastropietro [mailto:mastropi at uwalumni.com] 
> Sent:	Tuesday, July 23, 2002 3:13 AM
> To:	r-help at stat.math.ethz.ch
> Subject:	[R] Removing columns from data frame
> 
> Hello,
> 
> Is there an easy way to remove a few columns from a data frame by 
> indicating the column names? I am thinking of an operator like the "-" to 
> remove the columns when referenced by column number, and I don't want to 
> use the %in% operator together with the names() function.
> 
> Thanks
> Daniel Mastropietro
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
> -.-.-
> r-help mailing list -- Read
> http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
> _._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list