Uses the numeric position of the letters in a word to create a numeric value for a word.

word_value(words, dtOut = FALSE)

Arguments

words

The input vector of words.

dtOut

Logical. Should the output be a data.table comprising the words and the values. Defaults to FALSE.

Value

A named numeric vector or a data.table.

Details

The function converts the input to lowercase, removes anything that is not between the letters "a" and "z", and transliterates accented characters to their ASCII equivalent before converting the word to a numeric value.

References

http://stackoverflow.com/q/36097446/1270695

Author

Ananda Mahto and Jota.

Examples

myvec <- c("and", "dad", "cat", "fox", "mom", "add", "dan", "naive", "non-descript") word_value(myvec)
#> and dad cat fox mom add #> 19 9 24 45 41 9 #> dan naive nondescript #> 19 51 137
word_value(myvec, TRUE)
#> word value #> 1: and 19 #> 2: dad 9 #> 3: cat 24 #> 4: fox 45 #> 5: mom 41 #> 6: add 9 #> 7: dan 19 #> 8: naive 51 #> 9: nondescript 137