Hi everybody, Does anyone know how to delete certain rows (satisfying a particular condition) of a data frame in R? Thanks u, Shubha [[alternative HTML version deleted]]
Try ?subset. See the following example. nm <- rownames(state.x77) start_with_M <- nm %in% grep("^M", nm, value=TRUE) subset(state.x77, start_with_M, Illiteracy:Murder) -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Shubha Vishwanath Karanth Sent: Monday, November 20, 2006 2:20 PM To: r-help at stat.math.ethz.ch Subject: [R] To delete rows in a dataframe Hi everybody, Does anyone know how to delete certain rows (satisfying a particular condition) of a data frame in R? Thanks u, Shubha [[alternative HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch 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.
Shubha I guess you've had numerous replies to this off-list, but just in case you haven't .... df[!(your condition),] HTH Peter Alspach> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Shubha > Vishwanath Karanth > Sent: Monday, 20 November 2006 9:50 p.m. > To: r-help at stat.math.ethz.ch > Subject: [R] To delete rows in a dataframe > > Hi everybody, > > > > Does anyone know how to delete certain rows (satisfying a particular > condition) of a data frame in R? > > > > Thanks u, > > Shubha > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >______________________________________________________ The contents of this e-mail are privileged and/or confidenti...{{dropped}}