Re: [R] remove multiple columns by name from dataframe

2009-07-23 Thread Anne Skoeries
That works perfekt! Thanks so much! -- Anne Skoeries __ 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-cont

Re: [R] remove multiple columns by name from dataframe

2009-07-23 Thread jim holtman
try this: data <- data[, !(names(data) %in% delete)] On Thu, Jul 23, 2009 at 9:49 AM, Anne Skoeries wrote: > Hi there, > > I'm trying to remove multiple columns by name from a data.frame. As a > result I need to get back the modified data.frame without the removed > columns. My columns I want to

Re: [R] remove multiple columns by name from dataframe

2009-07-23 Thread Sarah Goslee
There are several ways to do it. Here's one: fakedata <- data.frame(col1 = runif(10), col2 = runif(10), col3 = runif(10)) delete <- c("col1", "col3") fakedata2 <- fakedata[, !(colnames(fakedata) %in% delete), drop=FALSE] Sarah On Thu, Jul 23, 2009 at 9:49 AM, Anne Skoeries wrote: > Hi there, > >

Re: [R] remove multiple columns by name from dataframe

2009-07-23 Thread Jorge Ivan Velez
Dear Anne, Check out http://www.nabble.com/correct-way-to-subset-a-vector-to24412577.html#a24412577 for alternatives. HTH, Jorge On Thu, Jul 23, 2009 at 9:49 AM, Anne Skoeries wrote: > Hi there, > > I'm trying to remove multiple columns by name from a data.frame. As a > result I need to get