hash-accessors {hash}R Documentation

Accessor methods for the hash class.

Description

R style accesors for the hash-class.

Details

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.

Value

$ 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.

Author(s)

Christopher Brown

See Also

hash, .set, as.list.hash

Examples

  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


[Package hash version 1.0.2 Index]