Re: [R] extract columns from a dataframe

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon 05 Jul 2004 - 23:02:08 EST


myDF[! names(myDF) %in% not_wanted]

if I understand you aright. E.g.

library(MASS)
hills[! names(hills) %in% "climb"]

which can also be done by

subset(hills, select=-climb)

On Mon, 5 Jul 2004, Rado Bonk wrote:

> 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?

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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:05:39 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:41 EST