simLists object to a data.tableR/as.data.table-simLists.R
as.data.table.simLists.RdThis is particularly useful to build plots using the tidyverse, e.g., ggplot2.
Ported here from the now-unmaintained SpaDES.experiment package.
# S3 method for class 'simLists'
as.data.table(
x,
keep.rownames = FALSE,
...,
vals,
objectsFromSim = NULL,
objectsFromOutputs = NULL
)An R object.
Default is FALSE. If TRUE, adds the input object's names as a separate column named "rn". keep.rownames = "id" names the column "id" instead. For lists and when calling data.table(), names from the first named vector are extracted and used as row names, similar to data.frame() behavior.
Additional arguments. Currently unused.
A (named) list of object names to extract from each
simList, or a named list of quoted expressions to calculate for each simList,
or a mix of character and quoted expressions.
Character vector of objects to extract from the simLists. If
omitted, it will extract all objects from each simList in order to calculate the
vals. This may have a computational cost. If NA, then no objects will be
accessed from the simList. Objects identified here will only be as they are in
the simList, i.e., at end(sim).
List of (named) character vectors of objects to load from the
outputs(sim) prior to evaluating vals. If there already is an object
with that same name in the simList, then it will be overwritten with
the object loaded from outputs(sim). If there are many objects with the
same name, specifically from several saveTime values in the outputs(sim),
these will all be loaded, one at a time, vals evaluated one at a time, and
each of the values will be returned from each saveTime.
A column, saveTime, will be part of the returned data.table.
For cases where more than one object is required at a given
saveTime, all should be identified here, without time specified.
This function will take all identified objects from the same time period.
This returns a data.table class object.
See examples.