replace.list {anchors}R Documentation

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

An updated list will be returned – note that the original

Note

'old' is unchanged: remember to assign the result.

Also, this is recursive function if 'new' is a list of lists.

Author(s)

Jonathan Wand http://wand.stanford.edu

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


  ## 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)


[Package anchors version 3.0-8 Index]