keys: keys - get/set key(s) from a hash

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Returns the key(s) from a hash, unsorted by default

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
keys(x, ...)

## S4 method for signature 'hash'
keys(x, sorted = getOption("hash.sorted", FALSE))

## S4 method for signature 'hash'
names(x)

keys(x) <- value

## S4 replacement method for signature 'hash,ANY'
keys(x) <- value

## S4 replacement method for signature 'hash,ANY'
keys(x) <- value

## S4 replacement method for signature 'hash,'NULL''
keys(x) <- value

Arguments

x

A hash() object.

...

Used to allow for additional arguments for keys

sorted

logical; whether the keys should be sorted (DEFAULT: getOption('hash.sorted', FALSE))

value

character or object coercable to character

Details

Returns the character vector containing the keys of a hash object. By default, the responses are not sorted. Set sorted=TRUE to return keys in sort order.

names uses base::names and will always return a sorted list of names. keys should generally be used in favor of names, but names can be useful if you want sorted names for one instance when all others don't provide a sorted list.

Value

For keys and names, a character vector of key names For the replacement methods keys<-, a hash object with the keys renamed to value

Author(s)

Christopher Brown

See Also

Examples

1
2
3
4
5
6
7
  h <- hash( letters, 1:26 )
  keys(h)  # letters

  names(h) # same
  
  #' Rename keys
  # keys( h ) <- rev( keys(h) ) 

decisionpatterns/r-hash documentation built on Feb. 6, 2019, 10:27 p.m.