Displaying 1 result from an estimated 1 matches for "possiblecharact".
2008 Nov 24
4
Calculating sum of letter values
Hi all
If I have a string, say "ABCDA", and I want to convert this to the sum of the letter values, e.g.
A -> 1
B -> 2
etc, so "ABCDA" = 1+2+3+4+1 = 11
Is there an elegant way to do this? Trying something like
which(LETTERS %in% unlist(strsplit("ABCDA", "")))
is not quite correct, as it does not count repeated characters. I guess what I need is