GenerateRegularDailyTS: GenerateRegularDailyTS

View source: R/GenerateRegularDailyTS.R

GenerateRegularDailyTSR Documentation

GenerateRegularDailyTS

Description

Generates a regular time series with daily resolution out of an daily but irregular time series.

Usage

GenerateRegularDailyTS(TimeChar, Datavec, na.rm = TRUE, format = '%Y-%m-%d',

tz = 'UTC',option = 'stine',Header=c('Time','Data'), Start,End, PlotIt = FALSE,

AggregateFun=sum,...)

Arguments

TimeChar

[1:n] Time in character or date format

Datavec

[1:n] numerical data vector

na.rm

Either TRUE, FALSE, zero, mean, min, max, ff: ForwardFill or ,bf: BackwardFill, weighted_ff, weighted_bf

format

if not default, then check strptime function

tz

sometimes durations and time difference cannot be calculated if timezone is not chosen, default: 'UTC'

option

in case of na.rm=TRUE the option of interpolation: "linear", "spline" or "stine" . Please see na.interpolation documentation for further details

Header

Optional, Default is c('Time','Data') vector of character defining the two column names of the tibble data frame.

Start

Optional, as.Date object defining the beginning of the timeseries, default is the minimum point of time in TimeChar

End

Optional, as.Date object defining the ending of the timeseries, default is the minimum point of time in TimeChar

PlotIt

TRUE: plotting, FALSE: no plots

AggregateFun

Optional, in the special case that there are several values in Datavec per date in TimeChar a warning is given back but the Datavec values can be aggregated by a function defined with this argument. This function has to have an na.rm argument, such like mean or sum because missing values are ignored in the aggregation process.

...

in the case that AggregateFun is needed, further argument for aggregate, see example

Details

Regular spaced time series with missing values filled depending on na.rm choice. The choices are

ff - ForwardFill: The first value before a NaN defines all NaN until the next value is available

bf - BackwardFill: The last value after a NaN defines all NaN before that value

zero: NaN are replaced with zeros

mean/min/max: NaN are replaced with the average/minimum/maximum of Datavec

weighted_ff/weighted_bf: The either weighted ForwardFill or BackwardFill. weighted means that the relevant value is normalized by the number NaN before or after and this value replaces the given value and all relevant NaN

Value

Regular TS of equidistance as a tibble data frame

Author(s)

Michael Thrun

See Also

GenerateRegularNonDailyTS

Examples

##tobefilled

## Not run: 
#take the last value of a day
V=GenerateRegularDailyTS(Time,Price,Header = c("UTC_Time","Price"),na.rm = "ff",AggregateFun = tail,n=1)

## End(Not run)

Mthrun/TimeSeries documentation built on Feb. 6, 2024, 9:23 a.m.