apply.hourly: aggregate xts object to hourly values

View source: R/functions.r

apply.hourlyR Documentation

aggregate xts object to hourly values

Description

Aggregate an xts object to hourly values. It is a wrapper of period.apply with endpoints = "hours"

Usage

apply.hourly(x, FUN, roundtime = "round", na.rm = TRUE)

Arguments

x

xts object

FUN

function to apply to x

roundtime

character. Valid are NA, "round", and "trunc", See details

na.rm

logical. Should ne values be removed?

Details

An xts object is aggregated to hourly values. Using the parameter roundtime, the timestamp of the xts object can be round to full hours. This can be done by rounding to the nearest full hour, or by going to the last full hour (trunc). NA skips rounding.

Author(s)

Simon Frey

See Also

period.apply

Examples

    library(TigR)
    library(xts)
    x <- xts(runif(6,1,100), order.by = as.POSIXct(c("2000-01-20 10:55","2000-01-20 10:59","2000-01-20 11:20","2000-01-20 12:35", "2000-01-20 12:45", "2000-01-20 13:45")))
    apply.hourly(x, FUN = mean, roundtime = "round")

freysimon/TigR documentation built on Jan. 26, 2024, 9:01 a.m.