Learn R Programming

anchors (version 3.0-8)

replace.list: Updating contents of one list using a second list

Description

Update or insert named elements into a list using a second source list.

Usage

replace.list( old, new )

Arguments

old
The target list to be updated
new
The soure list whose elements will be inserted into 'old'

Value

References

Wand, Jonathan; Gary King; and Olivia Lau. (2007) ``Anchors: Software for Anchoring Vignettes''. Journal of Statistical Software. Forthcoming. copy at http://wand.stanford.edu/research/anchors-jss.pdf

Wand, Jonathan and Gary King. (2007) Anchoring Vignetttes in R: A (different kind of) Vignette copy at http://wand.stanford.edu/anchors/doc/anchors.pdf

See Also

anchors

Examples

Run this code

  ## replace y, and insert w
  a <- list( x = 1, y = 2, z = 3)
  b <- list( y = 4, w = 5)
  replace.list( a, b)

  ## recursive
  a <- list( x = list( y = 1, z = 2) )
  b <- list( x = list( y = 2, w = 3) )
  replace.list( a, b)

  ## if there is any disagreement between structure of old and new
  ## then structure of new list replaces structure of old list
  a <- list( x = 1, y = list( y=1,z=2))
  b <- list( x = list( y = 2, w = 3) , y = -9)
  replace.list( a, b)

Run the code above in your browser using DataLab