movingaves: Moving Averages

Description Usage Arguments Value Note Author(s) References See Also Examples

Description

This function returns either a vector of moving averages or the maximum moving average for some input vector x.

Usage

1
movingaves(x, window, return.max = FALSE, skipchecks = FALSE)

Arguments

x

Input vector.

window

Window length for moving averages.

return.max

If TRUE, function returns the maximum moving average; if FALSE, function returns a vector of moving averages.

skipchecks

If TRUE, function skips error checking code and runs slightly faster.

Value

Either a single numeric value indicating the maximum moving average, or a vector of length (length(x) - window + 1) with moving averages.

Note

Some additional information on the package accelerometry and its functions can be found on the author's website, https://sites.google.com/site/danevandomelen/

Author(s)

Dane R. Van Domelen

References

Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.

See Also

blockaves

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Load in sample data frame
data(unidata)

# Get data from ID number 21005
counts.part1 <- unidata[unidata[, "seqn"] == 21005, "paxinten"]

# Create vector of all 10-minute moving averages
all.10min.averages <- movingaves(x = counts.part1, window = 10)

# Calculate maximum 10-minute moving average
max.10min.average <- movingaves(x = counts.part1, window = 10, return.max = TRUE)

Example output



accelerometry documentation built on May 2, 2019, 5:23 p.m.