I want to build a hash in R. I installed the hash package in R.
I need to have integer keys. However, I cannot access them .
> y <- as.character(seq(0,10,1))
> y
[1] "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"
> h <- hash(key =y, values = 1:11)
> h
<hash> containing 2 key-value pair(s).
key : 0 1 2 3 4 5 6 7 8 9 10
values : 1 2 3 4 5 6 7 8 9 10 11
When I try to access the keys, it gave me a value of NULL.
> h[["0"]]
NULL
h$"0"
NULL
> h$0
Error: unexpected numeric constant in "h$0"
Is there a solution to this ?
?hashsays "Keys must be a valid R name, must be a character vector and must not be the empty string, ‘""’." Numbers are not generally considered valid R names.