[R] Row exclude

Val v@|kremk @end|ng |rom gm@||@com
Sat Jan 29 04:08:11 CET 2022


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,



More information about the R-help mailing list