simulate_traces()
provides a list of type traces_dm_list
,
containing arrays of type traces_dm
. The respective classes were created
to ensure convenient plotting and printing, but they are not really
necessary. If users want to create their own figures or access the values of
the simulated traces, the data types can even mask the underlying properties.
The goal of unpack_traces()
is to provide a convenient way to strip away
the attributes of traces_dm_list
and traces_dm
objects.
Usage
unpack_traces(object, ...)
# S3 method for class 'traces_dm'
unpack_traces(object, ..., unpack = TRUE)
# S3 method for class 'traces_dm_list'
unpack_traces(object, ..., unpack = TRUE, conds = NULL)
Arguments
- object
an object of type drift_dm or
fits_ids_dm
(see load_fits_ids)- ...
further arguments passed on to the respective method.
- unpack
logical, indicating if the
traces_dm
objects shall be unpacked. Default isTRUE
.- conds
optional character, indicating specific condition(s). The default
NULL
will lead toconds = conds(object)
. Thus, per default all conditions are accessed.
Value
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 traces_dm
, unpack_traces()
returns an array with the traces, if
unpack=TRUE
. If unpack=FALSE
, the unmodified object is returned.
Details
unpack_traces()
is a generic function to strip away the "unnecessary"
information of traces_dm_list
and traces_dm
objects. These objects are
created when calling simulate_traces()
.
For traces_dm_list
, unpack_traces()
returns the
requested conditions (see the argument conds
). The result contains
objects of type traces_dm
if unpack = FALSE
. For unpack = TRUE
,
the result contains the plain arrays with the traces.
Examples
# 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)
# and then unpack them to get the underlying arrays
str(unpack_traces(some_traces))
#> List of 2
#> $ comp : num [1:2, 1:3001] 0 0 -0.00901 0.02302 0.00726 ...
#> $ incomp: num [1:2, 1:3001] 0 0 -0.0714 0.0194 -0.0749 ...