This package provides an R
frontend to a C
implementation of
linear-time univariate total variation denoising via dynamic programming
(Johnson 2013).
You can install the development version of tvdenoising from GitHub with:
# install.packages("pak")
pak::pak("glmgen/tvdenoising")
library(tvdenoising)
y <- c(rnorm(30), rnorm(40, 2), rnorm(30))
yhat <- tvdenoising(y, 10)
plot(y, pch = 16)
lines(yhat, col = 2)