Description Usage Arguments Details Value See Also Examples
Override existing list entries and extract arguments that are specified as named lists
1 2 3 | modifyExistingList(x, val)
extractArg(arglist, deflist)
|
x |
a named list, the target for replacing with entries with the same name from |
val |
a named list that serves as template for filling in values in |
arglist |
a named list; these are the specified arguments that override the defaults. |
deflist |
a named list whose entries are all possible slots (with default values) that can be filled. |
modifyExistingList
is a general function that recursively overwrites named items in x
with the value of items of val
with the same name. Items in val
that have no name, or do not correspond to an item in x
with the same name, are ignored.
extractArg
is a specific helper function for setting default values for the annHeatmap2
-family of functions, where arguments are given as a list with two named items, Row
and Col
. Each of these items is again a named list of actual parameters. At the same time, all items with other names than Row
and Col
at the top level are assumed to be shared items with the same value for both sub-lists. extractArg
uses modifyExistingList
to overwrite the default values specified in deflist
with the actual values specified in arglist
, see Examples.
modifyExistingList
returns x
, with values replaced from val
where names match. extractArg
returns a list with items Row
and Col
fully specified according to both deflist
and arglist
.
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## Replace items with matching names recursively
x = list(a=1, b=2, c=list(a=31, b=32), 135)
val = list(a=2, c=list(b=1114), d=92)
modifyExistingList(x, val)
## Same defaults for rows/columns, no arguments specified
defs = list(a="A", b="B", c="C")
extractArg(NULL, defs)
## Shared and non-shared defaults
defs = list(common.1=134, common.2=72, Row=list(row.only=14), Col=list(col.only=134))
args = list(common.1 = -1, Row=list(row.only=94, common.2=-15))
extractArg(args, defs)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.