Hash R objects to 32bit integers
1 2 3 4 5 6 7 8 9 10 11 12
Object to hash
Arguments to be passed to other methods. In particular, for the default method,
these arguments are passed to
hash each element separately?
maximum number of threads used.
The default method
serializes the input to a single
raw vector which is then hashed to a single signed
integer. This is also true for
character vectors when
recursive=TRUE each element of a
character vector is hashed separately, based on the underlying
char representation in
On systems supporting openMP, this function is able to use multiple cores. By default, a sensible number of cores is chosen. See the entry on OpenMP Support in the writing R extensions manual to check whether your system supports it.
The hash function used is Paul Hsieh's'
SuperFastHash function which is
described on his website.
As the title of the algorithm suggests, this hashing algorithm is not aimed to
be used as a secure hash, and it is probably a bad idea to use it for that purpose.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# hash some complicated R object (not a list). m <- lm(height ~ weight, data=women) hash(m) # hash a character vector element by element: x <- c("Call any vegetable" , "and the chances are good" , "that the vegetable will respond to you") hash(x) # hash a character vector as one object: hash(x, recursive=FALSE) # hash a list recursively L <- strsplit(x," ") hash(L) # recursive really means recursive, so nested lists are recursed over: L <- list( x = 10 , y = list( foo = "bob" , bar = lm(Sepal.Width ~ Sepal.Length, data=iris) ) ) hash(L) hash(L,recursive=FALSE)