| trim_duplicates | R Documentation |
Removes adjacent duplicate values over the time axis, possibly from a probability vector or matrix (e.g. survival curves). Equality is determined with a numeric tolerance.
For matrices, duplicate detection is done column-wise across all rows. Only the earliest time point in each run of (near-)equal values is kept.
trim_duplicates(x, times = NULL, tol = 1e-10)
x |
( |
times |
( |
tol |
( |
A named list with:
x: numeric vector or matrix with duplicate adjacent time points removed.
times: numeric vector of retained time points.
# remove adjacent duplicates from a survival probability vector
surv = c(1, 1, 0.8, 0.8, 0.5, 0.5, 0.2)
trim_duplicates(surv, times = 1:7)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.