[R] erase columns

Gabor Grothendieck ggrothendieck at myway.com
Tue Sep 14 17:05:23 CEST 2004

michele lux <nedluk <at> yahoo.it> writes:

> Can somebody remember me which is the command to erase
> columns from a data frame?

To delete a single column assign NULL to it.  That works
because a data frame is a list and that works for lists.
Here are three examples of deleting column 5, the Species 
column, from the iris data set:

   iris[,5] <- NULL  

   iris$Species <- NULL

   iris[,"Species"] <- NULL

More information about the R-help mailing list