movingaverage {biosignalEMG}R Documentation

Moving average of an EMG


Smooths an EMG by taking local averages.


movingaverage(data, channel, wsize, units = c("samples", "time"),



an ‘emg’ object, usually rectified.


in case of multi-channel data, channel is the specific channel to be considered by the procedure. Possible values: a character vector specifying the name of the channel to be considered (case sensitive) or a numeric value specifying the channel to be considered (number of column in data).

wsize, units

determines the length of the moving window that is used to calculate the local averages of the data.

a string specifying the name of the variable which will appears on the plots. If empty or not provided is taken from the object given as data.


The moving average is a running average computed over a moving window over the length of the EMG. Usually, the EMG signal is first rectified due that, generally, the mean value of an EMG signal is zero.

The window length is the double of the value of wsize in samples. The units of the window size could be in number of samples ("samples") or in seconds ("time").


An ‘emg’ object containing the moving-averaged EMG.


J.A. Guerrero


Konrad P. (2005) The ABC of EMG: A Practical Introduction to Kinesiological Electromyography. Version 1.0, Noraxon INC. USA.

See Also

rectification, filter


# change graphical parameters to show multiple plots
op <- par(mfrow = c(2, 1))

# Simulate 5 seconds of an EMG
emgx <- syntheticemg(n.length.out = 5000, = 1, on.duration.mean = 350, = 10, = 0.05, off.duration.mean = 300, = 20, 
    on.mode.pos = 0.75, shape.factor = 0.5, samplingrate = 1000, units = "mV", = "Synthetic EMG")
plot(emgx, main = "Synthetic EMG")

# Compute the moving average of the rectified EMG
emgr <- rectification(emgx, rtype = "fullwave")
emgma <- movingaverage(emgr, wsize = 30, units = "samples")
plot(emgma, main = "Moving average of the rectified EMG")

# reset graphical parameters

[Package biosignalEMG version 2.1.0 Index]