[R] Converting english words to numeric equivalents

baptiste auguie ba208 at exeter.ac.uk
Mon Jul 28 11:29:22 CEST 2008


Here is my attempt at this (taking a specific understanding of the ill- 
defined "equivalence" relation),

unletter <- function(word){
	
	word.broken <- strsplit(word, NULL)
	set.of.numbers <- sapply(word.broken[[1]], function(let) which(let ==  
letters))
	paste(set.of.numbers, sep="", collapse="")
}

unletter("abc")
# "123"
unletter("xyz")
# "242526"
unletter("salut")
# "191122120"


>>> Hello,
>>>
>>> I am trying to convert english words to numeric equivalents, e.g.,  
>>> abc to
>>> 123. Is there a function or library or package for doing this in  
>>> R? If not,
>>> can it be done easily in R?
>>

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag



More information about the R-help mailing list