Learn R Programming

accelerometry (version 2.2.5)

blockaves: Block Average Calculator

Description

This function returns averages for non-overlapping segments of data.

Usage

blockaves(x, window, skipchecks = FALSE)

Arguments

x

Input vector.

window

Window length.

skipchecks

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

Value

Vector of length floor(length(x) / window)

References

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

See Also

movingaves

Examples

Run this code
# NOT RUN {
# Load in sample data frame
data(unidata)

# Get data from ID number 21005, Saturday only
counts.saturday <- 
   unidata[unidata[, "seqn"] == 21005 & unidata[, "paxday"] == 7, "paxinten"]

# Calculate and plot hourly count averages
hourly.averages <- blockaves(x = counts.saturday, window = 60)
plot(hourly.averages)
# }

Run the code above in your browser using DataLab