Learn R Programming

simsalapar (version 1.0-2)

varlist: Variable Specification List - Generation and Class

Description

Generate variable specification lists. These are objects of the formal (aka S4) class "varlist". This class simply extends "namedList" and has a validity method (see validObject).

Usage

varlist(...)
dimnames2varlist(dmn)## S3 method for class 'varlist':
show(object)

Arguments

...
of the form [object Object],[object Object],[object Object],[object Object] i.e, a list of variable specifications using sub lists list(....) = list(value = , type = , expr = ),
dmn
named dimnames, a list.
object
a "varlist" object.

Value

  • an object of formal (aka S4) class "varlist".

Details

value is typically an atomic vector (is.atomic) or a list, e.g., of functions; in the latter case, typically with names.

type can be one of "N", "frozen", "grid", or "inner". In short: [object Object],[object Object],[object Object],[object Object] For more details, see Hofert and Mächler{Maechler} (2014), and also the examples in demo(package="simsalapar").

See Also

namedList; getEl for easy extraction of elements from a "varlist".

The toLatex method for varlists, toLatex.varlist.

doLapply(), doForeach(), doRmpi(), doMclapply(), doClusterApply() for the functions to iterate over the virtual grid.

Examples

Run this code
showClass("varlist")

vList <- varlist(
    n.sim = list(value = 1000, expr = quote(N[sim])), # type = N
    n     = list(type="grid", value = c(20, 100, 500)), # sample sizes
    meth  = list(type="grid", expr = quote(italic(method)),
                 value = c("classical", "robust")),
    alpha = list(value = 0.95)) # type = "frozen"

str(vList)# note the default 'expr' for  n and alpha; and type of alpha

## For more extensive examples, see also
demo(package="simsalapar")

## coerce to simple list  .. and back :
lvl <- as(vList, "list")
stopifnot(identical(
    do.call(varlist, lvl),
    vList ))

## From a data.frame to a LaTeX table :
arrTitan <- as.table(Titanic)
vlTitan <- dimnames2varlist(dimnames(arrTitan))
vlTitan
toLatex(vlTitan)

Run the code above in your browser using DataLab