unpack_obj | R Documentation |
When calling simulate_traces()
, calc_stats, or
coef.fits_ids_dm the returned objects will be custom objects
(e.g., subclasses of list or data.frame). The respective subclasses were
created to provide convenient plotting and printing, but they don't
really provide any additional functionality.
The goal of unpack_obj()
is to provide a convenient way to strip away
the attributes of the respective objects (revealing them as standard
arrays, data.frames, or lists).
unpack_obj(object, ...)
## S3 method for class 'traces_dm'
unpack_obj(object, ..., unpack_elements = TRUE)
## S3 method for class 'traces_dm_list'
unpack_obj(object, ..., unpack_elements = TRUE, conds = NULL)
## S3 method for class 'stats_dm'
unpack_obj(object, ..., unpack_elements = TRUE)
## S3 method for class 'stats_dm_list'
unpack_obj(object, ..., unpack_elements = TRUE, type = NULL)
## S3 method for class 'coefs_dm'
unpack_obj(object, ..., unpack_elements = TRUE)
object |
an object of type |
... |
further arguments passed on to the respective method. |
unpack_elements |
logical, indicating if the |
conds |
optional character vector, indicating specific condition(s). The
default |
type |
optional character vector, indicating specific type(s) of
statistics. The default |
unpack_obj()
is a generic function to strip away the custom information
and class labels of stats_dm
, stats_dm_list
, traces_dm
,
traces_dm_list
, and coefs_dm
objects. These objects are created when
calling simulate_traces()
, calc_stats, or
coef.fits_ids_dm.
For traces_dm_list
, unpack_obj()
returns the
requested conditions (see the argument conds
). The result contains
objects of type traces_dm
if unpack_elements = FALSE
. For
unpack_elements = TRUE
, the result contains the plain arrays with the
traces.
For stats_dm_list
, unpack_obj()
returns the
requested statistics (see the argument type
). The result contains
objects of type stats_dm
if unpack_elements = FALSE
. For
unpack_elements = TRUE
, the result contains the plain data.frames with
the statistics.
For traces_dm_list
, the returned value is a list, if conds
specifies more
than one condition. For example, if conds = c("foo", "bar")
, then the
returned value is a list with the two (named) entries "foo" and "bar". If
the returned list would only have one entry (either because the
traces_dm_list
has only one condition, see conds, or because a
user explicitly requested only one condition), then the underlying
array or traces_dm
object is returned directly.
For stats_dm_list
, the returned value is a list, if type
specifies more
than one condition. If the returned list would only have one entry, then
the underlying data.frame or stats_dm
object is returned directly.
For traces_dm
, unpack_obj()
returns an array with the traces, if
unpack=TRUE
. If unpack=FALSE
, the unmodified object is returned.
For stats_dm
, unpack_obj()
returns a data.frame with the respective
statistic, if unpack=TRUE
. If unpack=FALSE
, the unmodified object is
returned.
For coefs_dm
, unpack_obj()
returns a data.frame with the
parameters, if unpack=TRUE
. If unpack=FALSE
, the unmodified object is
returned.
# get a pre-built model to demonstrate the function
my_model <- dmc_dm()
# get some traces ...
some_traces <- simulate_traces(my_model, k = 2, seed = 1)
some_traces <- some_traces$comp
class(some_traces)
# ... unpack them to get the underlying arrays
class(unpack_obj(some_traces))
# get some statistics ...
some_stats <- calc_stats(my_model, type = "cafs")
class(some_stats)
class(unpack_obj(some_stats))
# get some parameters ...
some_coefs <- coef(get_example_fits_ids())
class(some_coefs)
class(unpack_obj(some_coefs))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.