What I want to do is implement a hash trick in R.
Code below:
library(digest)
a<-digest("key_a", algo='xxhash32')
#[1] "4da5b0f8"
This returned a hash code in a character type. Is there any way I can turn it into a integer? Or is there any other package to achieve this?
That output is a hex (base 16) string. Use following function to change it to decimal. Taken from another forum post but link does not work anymore (2017).
Output
But better answer is strtoi: as @Andrie said and @Gedrox answered, base::strtoi function works in the same way.
There is a built in function
base::strtoi
: