[R] Remove

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Sat Jan 29 14:17:24 CET 2022


Hello,

This question is repeated [1].

[1] https://stat.ethz.ch/pipermail/r-help/2022-January/473663.html

Rui Barradas

Às 02:20 de 29/01/2022, Val escreveu:
> Hi All,
> 
> I want  remove row(s) that contains 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 any  digit then remove that row
> 
> Desired output
> 
>     Name   Age weight
> 1   Bob     25    142
> 2   Carol   24    120
> 3   Katy    35    160
> 
> Thank you,
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using 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.



More information about the R-help mailing list