I have a data.frame with let’s say 5 columns and 30 rows. I iterate over each column and use the grep function to identify rows that are not numeric by looking for letters a-Z. I did quite some tests and it seemed to work fine. However, I just had a case where a number was 0.0000000009 which was translated by R to 9e-10. This row/number was identified by grep as being not numeric even though it is, apparently, a number. My question is now, how can I grep for letters a-Z but exclude the pattern “e-“? Here’s my R code:
for(i in 1:ncol(m)) {
if(length(grep("[a-zA-Z]", m[,1])) > 0) { # do something...}
}
Just to write it as an answer:
Ignore the warning from
as.numeric.