[R] Converting english words to numeric equivalents

Hans-Joerg Bibiko bibiko at eva.mpg.de
Mon Jul 28 12:23:58 CEST 2008


How about this?

unletter <- function(word) {
   gsub('-64',' ',paste(sprintf("%02d",utf8ToInt(tolower(word)) -  
96),collapse=''))
}

unletter("abc")
[1] "010203"

unletter("Aw")
[1] "0123"

unletter("I walk to school")
[1] "09 23011211 2015 190308151512"

--Hans



More information about the R-help mailing list