繁体   English   中英

如何根据特定条件删除行

[英]How to remove rows based on a particular condition

数据集包含一列,其中包含超过10000个手机号码,还包含一些没有特定格式的垃圾值。 如何仅保留具有正确手机号码的行

手机号码............评论

9674544444 ...... a

9453453455 .............................. c

asd..as23 ..................... d

作为sas E2 .......... d

232dsasd ..................................... 、、、、、、、、、、、、、、、、、、、、、 231


必填表

手机号码............评论

9674544444 ...... a

9453453455 .............................. c

像这样;

df<-read.table(header=T,sep="|",text="cell number|comment
9674544444|a
9453453455|c
asd..as23|d
as sas E2|d
232dsasd|23,,,,,231")

df[grep("[0-9]{10}",df$cell.number),]

#  cell.number comment
#1  9674544444       a
#2  9453453455       c

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM