Learn R Programming

simsalapar (version 1.0-5)

array-stuff: Tools For Converting To and From Arrays, Lists, and Array of Lists

Description

[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Usage

ul(x)

mkAL (x, vList, repFirst, check=TRUE) saveSim(x, vList, repFirst, sfile, check=TRUE, doAL=TRUE)

maybeRead(sfile, msg=TRUE)

getArray(x, comp=c("value", "error", "warning", "time"), FUN=NULL, err.value=NA)

array2df(x, responseName = "value")

Arguments

x
for [object Object],[object Object],[object Object],[object Object]
vList
a list of variable specifications. Each variable specification is itself a named list which must contain a "value" component.
repFirst
logical; must match the value of repFirst in the x <- do*Apply() call where x has been created.
check
logical activating consistency checks for x.
sfile
a file name, typically with extension .rds or NULL.
doAL
logical indicating if mkAL() should be called, or rather just x be saved.
msg
logical indicating whether a message is printed when an object is read from sfile.
err.value
numeric which is used to replace the value of the array entry in case of an error.
comp
character string denoting the component.
FUN
function to be applied right before the resulting array array is constructed.
responseName
(for arrady2df():) a string specifying the name of the value column of the resulting data frame.

Value

  • For [object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Details

mkAL() is useful when creating arrays from result lists returned from large(r) simulation studies which use doCallWE(). To create a proper argument x for mkAL(), the function ul() turns out to be useful to (stepwise) unlist nested lists.

getArray() converts arrays of lists as returned by mkAL() to an array of numeric (or logical, see below) after applying the specified FUN. In case of an error, the corresponding entry in the resulting array is replaced by err.value.

The default FUN converts possible errors and warnings to logical (indicating whether there was a error or warning, respectively) and run times to numeric. For comp="value", the situation is trickier. First of all, the resulting array contains dimensions for variables of type inner and, if greater than 1, for the variable of type N (typically called "n.sim"); see the vignette for details. Use FUN = identity to get at the full error or warning objects, for comp = "error" or for comp = "warning", respectively.

saveSim() and maybeRead() are useful for creating and (re)storing arrays from large(r) simulation studies (to avoid recomputation, to ease the data analysis etc.). saveSim() calls mkAL(), nowadays wrapped in tryCatch(.), such that the simulation is not lost, even when the resulting format cannot correctly be treated by mkAL(). Consequently, doAL is not much needed anymore. Note that both saveSim() and maybeRead() accept sfile=NULL in which case nothing is saved or read.

References

see simsalapar-package.

See Also

getEl() and mkNms() used by mkAL(). saveRDS() and readRDS(), the workhorses of saveSim() and maybeRead(), respectively.

Examples

Run this code
## Get at the full error objects, notably (message, call):
errObjs <- getArray(res, "error", FUN=identity)

if(FALSE) ## A longer, "interesting" example is in
 demo(robust.mean)

Run the code above in your browser using DataLab