h <- hash( keys=letters, values=1:26 ) h <- hash( letters, 1:26 )
2,取出一个哈希对
h[“a”]
3,取出某个键对应的值
h[[“a”]]
4,清空元素
clear(h)
5,删除这个哈希
rm(h)
6,循环赋值(也可以用于单独赋值)
h<-hash() for (i in 1:7296) { .set(h, keys = row.names(drug)[i], values = as.vector(drug[i,1])) } h.new<-h只是将h链接到了h.new, h.new<-copy(h)可以实现独立的复制
7,删除键值为a的元素
del(“a”,h)
8,has.key(“a”,h) 判断有没有键a, 返回TRUE或FALSE
9,is.hash(h) 判断是否为哈希
10,is.empty signature(x = “hash”): Test if no key-values are assigned
11,length signature(x = “hash”): Return number of key-value pairs from the hash
12,invert(h) 交换h的键值对
13,make.keys(key) Given an vector of any type, make.keys tries to coerce it into a character vector that can be used as a hash key. This is used internally by the hash package and should not be normally needed.