Re: [R] Converting english words to numeric equivalents

From: baptiste auguie <ba208_at_exeter.ac.uk>
Date: Mon, 28 Jul 2008 11:15:47 +0100

As you point out, my proposed function does not verify an equivalence, and it is not restricted to english words. I'm probably too keen to see questions that call for an answer with relaxed assumptions (understand, that i can manage).

Cheers,

baptiste         

On 28 Jul 2008, at 10:47, (Ted Harding) wrote:

> On 28-Jul-08 09:29:22, baptiste auguie wrote:

>> 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"
>     Ay        [yes, I understand]
>

>> unletter("xyz")
>> # "242526"
>     bdbebf
>

>> unletter("salut")
>> # "191122120"
>     aikbut    [or do I?]
>

>>>>> 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
>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding_at_manchester.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 28-Jul-08                                       Time: 10:47:13
> ------------------------------ XFMail ------------------------------
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 28 Jul 2008 - 10:19:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 28 Jul 2008 - 11:32:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive