Skip to contents

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.

Usage

alignComponents(DT, align = "max")

Arguments

DT

LONG data.table(t, OCID, s, DIR) for ONE record.

align

"max" (default) or "min".

Value

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.

Examples

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
#> [1] 3