I use the hash library and would like to use the vector as a key, however, it wants to assign each of the values โโin the vector, but I want to use the vector itself as a key. How can I set and access hash elements to achieve this? I would like to do something like this:
library(hash) h <- hash() inc <- function(key) { if(has.key(c(key), h)) { h[[key]] = h[[key]] + 1 } else { h[[key]] = 1 } } inc(c('a', 'b'))
And enter the key c('a', 'b') and the value 1 in the hash. Whenever I pass the same vector, the value is incremented by one.
I understand that this is normal behavior in R, as it is an array programming language, but I would like to avoid this in this case.
source share