Tally the Scrabble letter values of text given a user-supplied function, such as the sum (default) or mean of the character values.

nscrabble(x, FUN = sum)

Arguments

x a character vector function to be applied to the character values in the text; default is sum, but could also be mean or a user-supplied function

Value

a (named) integer vector of Scrabble letter values, computed using FUN, corresponding to the input text(s)

Note

Character values are only defined for non-accented Latin a-z, A-Z letters. Lower-casing is unnecessary.

We would be happy to add more languages to this extremely useful function if you send us the values for your language!

Examples

nscrabble(c("muzjiks", "excellency"))#> [1] 29 24nscrabble(texts(data_corpus_inaugural)[1:5], mean)#> 1789-Washington 1793-Washington      1797-Adams  1801-Jefferson  1805-Jefferson
#>        1.706789        1.721875        1.624590        1.678183        1.663654