This function depends on an existing `signal`-column (see tbl_mbte). The indexing function f is used to split a signal into subsignals. This function is useful, if only certain parts of a signal are relevant (e.g. remove parts, where the measured signal-values are below a specific threshold via a custom indexing-function).

mbte_extract_subsignals(x, f = mbte_default_indexer, ...)

Arguments

x

A tbl_mbte-object.

f

An indexing-function.

...

Additional arguments passed to `f`

Value

The original table gets returned. The `signal`-column is modified (since subsignals are extracted according to the indexing function f). Additionally, the column `signal_nr` is added, which indicates the number of the subsignal within the original signal.

e.g. Assuming that x only contains one row (hence only one element is present in the `signal`-list column). The indexing function f determines, that the signal contains 3 subsignals. Therefore, the original signal-tibble is split into 3 tibbles. The returned table will have 3 rows. The column `signal_nr` will be equal to c(1, 2, 3).

event-logging

This function logs unusual events. A warning gets raised at the end of an execution, if events have been logged. The event-log can be retrieved by passing the returned object to mbte_event_log. In this case, a tibble containing the logged events will be returned to the user.

event-log

The tibble containing event-information consists of 3 columns:

error

The unprocessed error, which occurred during execution.

row_nr

The row-number of the input-tibble (x), at which the error occurred.

signal

The signal-subtable processed at the time the error occurred.

NOTE: currently warnings are not logged.

See also

raw_signals (dataset used in examples)

Examples

library(dplyr, warn.conflicts = FALSE) data(raw_signals) # create nested tbl_mbte (needed for subsignal-extraction) tbl <- raw_signals %>% group_by(mv) %>% new_tbl_mbte(time = "t", value = "value") %>% mbte_nest_signals() # a signal-subtable with leading zeros (should be removed) tbl$signal[[9]]
#> # A tibble: 100 x 2 #> t value #> <int> <dbl> #> 1 1 0 #> 2 2 0 #> 3 3 0 #> 4 4 1.26 #> 5 5 9.39 #> 6 6 7.66 #> 7 7 9.33 #> 8 8 14.7 #> 9 9 4.27 #> 10 10 9.81 #> # … with 90 more rows
# perform subsignal extraction # # by default, mbte_default_indexer() gets used for signal-extraction # in this case only nonzero values are interesting extracted <- mbte_extract_subsignals(tbl) extracted
#> # A tibble: 86 x 3 #> mv signal_nr signal #> <chr> <int> <list> #> 1 mv1 1 <tibble [22 × 2]> #> 2 mv1 2 <tibble [8 × 2]> #> 3 mv1 3 <tibble [13 × 2]> #> 4 mv2 1 <tibble [5 × 2]> #> 5 mv3 1 <tibble [20 × 2]> #> 6 mv3 2 <tibble [22 × 2]> #> 7 mv4 1 <tibble [3 × 2]> #> 8 mv4 2 <tibble [9 × 2]> #> 9 mv4 3 <tibble [12 × 2]> #> 10 mv5 1 <tibble [30 × 2]> #> # … with 76 more rows