# Example with simulated data
x <- seq(1, 100, by = 1)
y <- sin(x/10) + 0.1*x + rnorm(100, 0, 0.1)
result <- rolling_ball(y, wm = 10)
plot(x, y, type = "l", col = "blue", main = "Rolling Ball Correction")
lines(x, result$baseline, col = "red", lwd = 2)
lines(x, result$corrected, col = "green")
legend("topright", c("Original", "Baseline", "Corrected"),
col = c("blue", "red", "green"), lty = 1)
Run the code above in your browser using DataLab