del: Remove key-value pair(s) from a hash

Description Usage Arguments Value Author(s) See Also Examples

Description

Removes key-value pair(s) from a hash by name of the object. There are also R-like methods described in Extract. To delete all keys, use clear().

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
del(x, hash)

## S4 method for signature 'ANY,hash'
del(x, hash)

## S4 method for signature 'character,hash'
del(x, hash)

delete(x, hash)

## S4 method for signature 'ANY,hash'
delete(x, hash)

Arguments

x

An object that will be coerced to valid key(s) to be removed from the hash. x will be coerced to a valid hash keys using make_keys()

hash

A hash() object

Value

None. This method exists solely for the side-effects of removing items from the hash.

Author(s)

Christopher Brown

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
  h <- hash( letters, 1:26 )
  
  # USING del 
  del( "a", h )             # delete key  a
  del( c("b","c"), h )      # delete keys b, c
  
  # USING rm  
  rm( "d", envir=h )              # delete key  d
  rm( list= c("e","f"), envir=h ) # delete keys e,f
  
  # USING R syntsx
  h$g <- NULL               # delete key  g
  h[['h']] <- NULL          # delete key  h
  h['i'] <- NULL            # delete key  i
  h[ c('j','k')] <- NULL    # delete keys e,f
   
  keys(h)
  D
  

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