Learn R Programming

tdata (version 0.3.0)

convert.to.daily: Convert Data to Daily Frequency

Description

Use this function to convert a time-series data (currently implemented: Date-List, Daily-In-Week) to a time-series data with daily frequency.

Usage

convert.to.daily(variable, aggregateFun = NULL)

Value

A variable with daily frequency, with data sorted from the original variable and missing dates filled with NA.

Arguments

variable

A variable.

aggregateFun

Function to aggregate data within each interval (see details).

Details

In some cases, conversion sorts the dates and fills any gaps between them with NA. However, in other cases, conversion requires aggregation. For example, when aggregating hourly data over a period of k hours to generate daily data, we expect k numbers in each interval. The aggregate function can be set to calculate the mean, variance, median, etc., or any function that takes the vector of k values and returns a number.

Examples

Run this code
startFreq <- f.list.date(c("20220904","20220901"), "20220901")
v <- variable(c(4,1), startFreq)
w <- convert.to.daily(v)

Run the code above in your browser using DataLab