hash-accessors {hash} | R Documentation |
R style accesors for the hash-class
.
These are the hash accessor methods. They closely follow an R style.
$
is a single value look-up operator. It returns the value for the
supplied key. The key name must be literal and will not be interpreted.
[[
is the look-up, extraction operator. It returns the values of
one keys. The key names will be interpreted. If you wish to extract
multiple keys, use the [
accessor.
[
is a subseting operator. It returns a (sub) hash with the specified
keys. All other keys are removed.
$ returns the value for the supplied key.
[ returns a hash slice, a sub hash with only the defined keys.
[[ returns a one or more values.
Christopher Brown
h <- hash() h <- hash( letters, 1:26 ) h$a h$a <- "2" h[[ "a" ]] # c("a","b","c","d") h[ letters[1:4] ] # hash with a,b,c,d h[ letters[1:4] ] <- 4:1