Colleagues, Hopefully a simple problem: I want to delete a column with a known name from a dataframe. I could write: FRAME <- FRAME[, names(FRAME) != NAMETODELETE] or FRAME <- FRAME[, !names(FRAME) %in% c(NAME1, NAME2, ETC)] Is there some simpler means to accomplish this? Dennis Dennis Fisher MD P < (The "P Less Than" Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-415-564-2220 www.PLessThan.com
Try this: FRAME$NAMETODELETE <- NULL On Tue, Sep 29, 2009 at 5:12 PM, Dennis Fisher <fisher at plessthan.com> wrote:> Colleagues, > > Hopefully a simple problem: I want to delete a column with a known name from > a dataframe. ?I could write: > > ? ? ? ?FRAME ? <- FRAME[, names(FRAME) != NAMETODELETE] > or > ? ? ? ?FRAME ? <- FRAME[, !names(FRAME) %in% c(NAME1, NAME2, ETC)] > > Is there some simpler means to accomplish this? > > Dennis > > > Dennis Fisher MD > P < (The "P Less Than" Company) > Phone: 1-866-PLessThan (1-866-753-7784) > Fax: 1-415-564-2220 > www.PLessThan.com > > ______________________________________________ > R-help at 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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
May be this: FRAME <- FRAME[-c(NAME1, NAME2)] or FRAME<- subset(FRAME, select=(-NAME1, -NAME2)) bests milton On Tue, Sep 29, 2009 at 4:12 PM, Dennis Fisher <fisher@plessthan.com> wrote:> Colleagues, > > Hopefully a simple problem: I want to delete a column with a known name > from a dataframe. I could write: > > FRAME <- FRAME[, names(FRAME) != NAMETODELETE] > or > FRAME <- FRAME[, !names(FRAME) %in% c(NAME1, NAME2, ETC)] > > Is there some simpler means to accomplish this? > > Dennis > > > Dennis Fisher MD > P < (The "P Less Than" Company) > Phone: 1-866-PLessThan (1-866-753-7784) > Fax: 1-415-564-2220 > www.PLessThan.com <http://www.plessthan.com/> > > ______________________________________________ > 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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
On 30/09/2009, at 9:15 AM, milton ruser wrote:> May be this: > > FRAME <- FRAME[-c(NAME1, NAME2)] > or > FRAME<- subset(FRAME, select=(-NAME1, -NAME2))This is ridiculous advice. Try things out before you suggest them. cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}