Learn R Programming

hash (version 3.0.1)

values: values

Description

Get/set values for a hash object

Usage

values(x, ...)

## S3 method for class 'hash': values(x, keys = NULL, ...)

values(x, ...) <- value

Arguments

docType

methods

See Also

Extract for R-like accessors

Examples

Run this code
h <- hash( letters, 1:26 )
  values(h)  # 1:26
  values(h, simplify = FALSE )
  values(h, USE.NAMES = FALSE )

  h <- hash( 1:26, letters )
  values(h)
  values(h, keys=1:5 )
  values(h, keys=c(1,1,1:5) )

  values(h, keys=1:5) <- 6:10
  values(h) <- rev( letters )

  # When values are obejcts
  h <- hash( c('a','b'), Sys.time() )
  class(h$a)             # "POSIXct" "POSIXt"
  vals <- values( h )
  class(vals)            # Numeric

  vals <- values(h, simplify=FALSE )
  class(vals)            # List
  class( Reduce( c, vals ) ) # "POSIXct" "POSIXt"

Run the code above in your browser using DataLab