Re: [R] Calculating sum of letter values

From: Stefan Evert <stefan.evert_at_uos.de>
Date: Mon, 24 Nov 2008 16:27:49 +0100

>
> Thanks, that's almost exactly what I need...theres just a slight
> difference with my requirement, in that I am looking for the actual
> index value in the alphabetical sequence, so that instead of:
>
> as.numeric(factor(unlist(strsplit("XYZ",""))))
> [1] 1 2 3
>
> I would expect to see
>
> [1] 24 25 26
>

How about this?

        as.numeric(factor(unlist(strsplit("ECX", "")), levels=LETTERS))

Best regards,
Stefan Evert

[ stefan.evert@uos.de | http://purl.org/stefan.evert ]



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 24 Nov 2008 - 15:29:57 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 24 Nov 2008 - 15:30:27 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