hash (version 3.0.1)

Extract: Extract

Description

These are the hash accessor methods. They closely follow the R style.

Usage

## S3 method for class 'hash,ANY,missing,missing':
[(x, i, j, ..., drop)

## S3 method for class 'hash,missing,missing,missing': [(x, i, j, ..., drop)

Arguments

docType

methods

See Also

del for removing keys clear for removing all keys

keys to get/set/rename keys values to get/set/edit values

set to set values internal method

hash

Examples

Run this code
h <- hash( c('a','b','c'), 1:3 )

  # NAMED ACCESS

  h$a  # 1
  h$c  # 3

  # class of values change automatically
  class(h$a)  # integer
  h$a <- 1.1
  class(h$a)  # numeric

  # values can contain more complex objects
  h$a <- 1:6
  h

  h$a <- NULL  # DELETE key 'a', will return null


  # INTERPRETED ACCESS

  h[[ "a" ]] <-"foo"    # Assigns letters, a vector to "foo"
  nm = "a"

  # SLICE ACCESS
  h[ nm ] <- "bar"   # h$a == bar
  h[ nm ] <- NULL


  # Slice
  h[ keys(h) ]
  h[ keys(h) ] <- list( 1:2, 1:3 )
  h

Run the code above in your browser using DataLab