smooth_data: Perform Data Smoothing with Loess

View source: R/16-smooth_data.R

smooth_dataR Documentation

Perform Data Smoothing with Loess

Description

This function performs data smoothing using the Loess method and opitonally plot the original data and smoothed data to visualize the effect of different span values on the smoothing process.

Usage

smooth_data(
  x,
  time,
  span,
  degree,
  should_plot = FALSE,
  color_original = "blue",
  color_smoothed = "red"
)

Arguments

x

A numeric vector of values to be smoothed.

time

A POSIXct or POSIXlt object representing the time points of the x values.

span

A numeric vector of span values to be used in the Loess smoothing.

should_plot

A logical value indicating whether to plot the original and smoothed data.

color_smoothed

The color to be used for the smoothed data in the plot. Default is "red".

color_orignal

The color to be used for the original data in the plot. Default is "blue".

Value

A list containing the original and smoothed data, as well as the span values used.

Author(s)

Zirui Qiang list("zirui_qiang@outlook.com")

Minghang Li list("minghli@ethz.ch")

Examples

data("step_data", package = "laggedcor")
x <- step_data$step
time <- step_data$time
span <- 0.1
degree <- 2

res <- smooth_data(x, time, span, degree, should_plot = TRUE)


jaspershen/laggedcor documentation built on June 10, 2025, 5:42 p.m.