The data set contains a column with over a 10000 cell phone numbers,it also contains some garbage values with no particular format. How do I retain only the rows with the correct cell phone numbers
cell number ............ comment
9674544444............... a
9453453455............... c
asd..as23.....................d
as sas E2...................d
232dsasd....................,,,,,,,,,,,,,,,23,,,,,231
required table
cell number ............ comment
9674544444............... a
9453453455............... c
Like this;
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.