On Sep 4, 2014, at 2:58 PM, Kuma Raj wrote: > This post has NOT been accepted by the mailing list yet.
Well, it has now. Were you earlier posting from Nabble? (Not an efficient strategy.) > I would like to subset a column based on the contents of a column with > specific character. In the sample data I wish to do the following: > > First keep the data based on column "prog" if prog contains "ca", and > secondly to drop if race contains "ic" > > Thanks > > library(foreign) > hsb2 <- read.dta('http://www.ats.ucla.edu/stat/stata/notes/hsb2.dta') > NROW( hsb2[ grepl("ca", hsb2$prog) & !grepl("ic", hsb2$race) , ] ) [1] 120 -- David Winsemius Alameda, CA, USA ______________________________________________ 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.