smoothTrajectory: Apply a moving average filter to the trajectory and create a...

View source: R/smoothTrajectory.R

smoothTrajectoryR Documentation

Apply a moving average filter to the trajectory and create a smoothed trajectory

Description

This function applies a moving average filter to the 'x' and/or 'y' coordinates of a "trajectory" object. The filter is applied using a window of a specified size. The function then creates a new trajectory object using the smoothed coordinates. The filter is applied symmetrically around each point.

Usage

smoothTrajectory(obj, method = c("x", "y", "both"), window = 3)

Arguments

obj

An object of class 'trajectory' that contains a component 'points', which is a data frame with the coordinates of the points. It is assumed that 'points' has columns 'x' and 'y' representing the trajectory coordinates.

method

A character string specifying which coordinate(s) to smooth. Can be one of '"x"', '"y"', or '"both"'. Default is '"both"', which smooths both the 'x' and 'y' coordinates.

window

An odd integer specifying the window size for the moving average filter. The window must be an odd number to ensure a symmetric filter. Default is 3.

Value

A new trajectory object created using the smoothed 'x' and 'y' coordinates.


BioTrajectory documentation built on Nov. 26, 2025, 5:07 p.m.