Shicheng-Guo / rbiotools

Other
0 stars 0 forks source link

detect non ascii characters in a string #2

Open Shicheng-Guo opened 3 years ago

Shicheng-Guo commented 3 years ago

How to solve this issue - detect non ascii characters in a string in devtools::check(--as-cran)?

the solution is to use grepl("[^ -~]", x) to find non-ASCII and then use stri_enc_toascii convert to ASCII

xx<-unlist(apply(impc,2,function(x) any(grepl("[^ -~]", x))))
which(xx)
library("stringi")
impc[,19]<-stri_enc_toascii(impc[,19])
usethis::use_data(impc,overwrite = T)