As character 'polluted' entries will cause a column to be read in (via read.table and relatives) as factor or character data, this sounds like a job for regular expressions. If you are not familiar with this subject, time to learn. And, yes, some heavy lifting will be required. See ?regexp for a start maybe? Or the stringr package?
Cheers, Bert On Fri, Jan 28, 2022, 7:08 PM Val <valkr...@gmail.com> wrote: > Hi All, > > I want to remove rows that contain a character string in an integer > column or a digit in a character column. > > Sample data > > dat1 <-read.table(text="Name, Age, Weight > Alex, 20, 13X > Bob, 25, 142 > Carol, 24, 120 > John, 3BC, 175 > Katy, 35, 160 > Jack3, 34, 140",sep=",",header=TRUE,stringsAsFactors=F) > > If the Age/Weight column contains any character(s) then remove > if the Name column contains an digit then remove that row > Desired output > > Name Age weight > 1 Bob 25 142 > 2 Carol 24 120 > 3 Katy 35 160 > > Thank you, > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.