~ubuntu-branches/ubuntu/oneiric/latticeextra/oneiric

« back to all changes in this revision

Viewing changes to R/utilities.R

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2007-04-12 23:44:23 UTC
  • mto: (3.1.1 gutsy) (1.3.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20070412234423-rbngmth8gbdghryf
Tags: upstream-0.1.6
ImportĀ upstreamĀ versionĀ 0.1.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
 
5
5
updateList <-
6
 
    function(x, val)
 
6
    function (x, val)
7
7
{
8
 
    if (is.null(x)) x <- list()
9
 
    if (!is.list(x)) stop("x must be NULL or a list")
10
 
    if (!is.list(val)) stop("val must be a list")
11
 
    xnames <- names(x)
12
 
    for (v in names(val))
13
 
    {
14
 
        existing <- v %in% xnames
15
 
        if (existing && is.list(x[[v]]) && is.list(val[[v]]))
16
 
            x[[v]] <- updateList(x[[v]], val[[v]])
17
 
        else 
18
 
            x[[v]] <- val[[v]]
19
 
    }
20
 
    x
 
8
    if (is.null(x))
 
9
        x <- list()
 
10
    modifyList(x, val)
21
11
}
22
12
 
23
13
 
24
14
 
25
 
 
26
 
 
27
 
 
28
15
## utility functions to extract components of a formula.  Don't work
29
16
## reliably with unusual symbols
30
17