Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

digest2int

hash arbitrary string to integer


Description

The digest2int function calculates integer hash of an arbitrary string. This is useful for randomized experiments, feature hashing, etc.

Usage

digest2int(x, seed = 0L)

Arguments

x

An arbitrary character vector.

seed

an integer for algorithm initial state. Function will produce different hashes for same input and different seed values.

Value

The digest2int function returns integer vector of the same length as input vector x.

Author(s)

Dmitriy Selivanov selivanov.dmitriy@gmail.com for the R interface; Bob Jenkins for original implementation http://www.burtleburtle.net/bob/hash/doobs.html

References

See Also

Examples

current <- digest2int("The quick brown fox jumps over the lazy dog", 0L)
target <- 1369346549L
stopifnot(identical(target, current))

digest

Create Compact Hash Digests of R Objects

v0.6.27
GPL (>= 2)
Authors
Dirk Eddelbuettel <edd@debian.org> with contributions by Antoine Lucas, Jarek Tuszynski, Henrik Bengtsson, Simon Urbanek, Mario Frasca, Bryan Lewis, Murray Stokely, Hannes Muehleisen, Duncan Murdoch, Jim Hester, Wush Wu, Qiang Kou, Thierry Onkelinx, Michel Lang, Viliam Simko, Kurt Hornik, Radford Neal, Kendon Bell, Matthew de Queljoe, Ion Suruceanu, Bill Denney, Dirk Schumacher, and Winston Chang.
Initial release
2020-10-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.