Learn R Programming

hash (version 3.0.1)

del: del, delete - remove key-value pair(s) from a hash

Description

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

Usage

del(x, hash)

## S3 method for class 'ANY,hash': del(x, hash)

## S3 method for class 'character,hash': del(x, hash)

delete(x, hash)

## S3 method for class 'ANY,hash': delete(x, hash)

Arguments

Value

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

docType

methods

See Also

rm base function used by del Extract for R-like accessor clear to remove all key-values and return an empty hash hash

Examples

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

Run the code above in your browser using DataLab