> df <- data.frame(x = runif(10), y = runif(10), z = runif(10))
> colnames <- names(df)
> df2 <- df[!colnames %in% c("x", "y")]
> df2
Cheers!!
Albert-Jan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public
order, irrigation, roads, a fresh water system, and public health, what have the
Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- On Mon, 5/31/10, suman dhara <suman.dhara89@gmail.com> wrote:
From: suman dhara <suman.dhara89@gmail.com>
Subject: [R] getting the column name of a data frame
To: r-help@stat.math.ethz.ch
Date: Monday, May 31, 2010, 7:33 AM
Sir,
I want to store the column name of a data frame as a vector and use the
vector to remove a column of the data frame ,if required.
Thanks,
Suman Dhara
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org 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.
[[alternative HTML version deleted]]