I have a list of 10 digit numbers, I want to extract the numbers beginning with 9, 8 or 7. How can I do it in excel or R ?
CodePudding user response:
We may use grep
grep("^[7-9]", yourvec, value = TRUE)
Or with %in%
after extracting the first character with substr
yourvec[substr(yourvec, 1, 1) %in% 7:9)]
CodePudding user response:
In Excel, if they have exactly ten digits:
=FILTER(A:A,(A:A>=7E9)*(A:A<1E10))