Learn R Programming

hash (version 1.0.3)

hash-accessors: Accessor methods for the hash class.

Description

R style accesors for the hash-class.

Arguments

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.

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.

See Also

hash, .set, as.list.hash

Examples

Run this code
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

Run the code above in your browser using DataLab