View source: R/alignComponents.R
| alignComponents | R Documentation |
Pads shorter OCIDs with trailing zeros (align = "max") or truncates
longer OCIDs (align = "min") so all components share the same NP.
Operates on a classified LONG table with columns t, OCID, s, and DIR.
alignComponents(DT, align = "max")
DT |
LONG |
align |
|
Named list with two elements:
DT : aligned LONG data.table with the same columns as the
input.
NP : integer, final number of samples per component after
alignment (the same for every OCID).
When every OCID already shares the same NP the function returns
without padding or truncation; the input is passed through as
DT unchanged.
x <- data.table::rbindlist(list(
data.table::data.table(t = c(0, 0.01, 0.02), OCID = "H1",
DIR = "H1", s = c(1, 2, 3)),
data.table::data.table(t = c(0, 0.01), OCID = "H2",
DIR = "H2", s = c(1, 2)),
data.table::data.table(t = c(0, 0.01, 0.02), OCID = "UP",
DIR = "UP", s = c(0, 1, 0))
))
aligned <- alignComponents(x, align = "max")
aligned$NP
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.