[R] Remove columns by name data[-c("subj","drug")]
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Feb 27 10:33:32 CET 2001
On Tue, 27 Feb 2001, Dieter Menne wrote:
> Is there an easy way to remove data frame columns
> by name instead of by index? The following gives
> the idea
>
> remove<-c("subj","drug")
> data[-remove]
>
> I found a solution with a few evals and substitutes,
> similar to that used in reshapeLong, but there must
> be an easier way out.
data[-match(remove, names(data))]
--
Brian D. Ripley, ripley at 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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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