ts_asfreq: Frequency Conversion Function of Setting Frequency of...

Description Usage Arguments Details Value Methods (by class) See Also

View source: R/utils-timeseries.R

Description

Generic function tp convert timeseries at specified frequency by setting new frequency of data index

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
ts_asfreq(
  ts_dataset,
  freq_rule = c("day", "month", "quarter", "year"),
  fillna_method = c("nfill", "ffill", "bfill"),
  ...
)

## S3 method for class 'tbl_df'
ts_asfreq(
  ts_dataset,
  freq_rule = c("day", "month", "quarter", "year"),
  fillna_method = c("nfill", "ffill", "bfill"),
  ...,
  date_index_field = c("date"),
  key_fields = NULL,
  parallel = getOption("zstmodelr.common.parallel", TRUE)
)

## S3 method for class 'timeSeries'
ts_asfreq(
  ts_dataset,
  freq_rule = c("day", "month", "quarter"),
  fillna_method = c("nfill", "ffill", "bfill"),
  ...
)

Arguments

ts_dataset

A timeseries of tibble/timeSeries.

freq_rule

A offset string or object representing target conversion, e.g. "day", "month", "quarter", "year", default "day".

fillna_method

A method to fill NAs in reindexed Series, e.g. "nfill", "ffill", "bfill" . Default "nfill" don't fill NAs; "ffill" means to use data before NAs to fill NAs; "bfill" means to use data after NAs to fill NAs.

...

Extra arguments to be passed to methods.

date_index_field

Name of date index field of ts_df for refrequecy, default 'date', Column must be date-like. Only be used for tibble dataset.

key_fields

A character vector of key fields, which identify unique observation in each date. Only be used for tibble dataset.

parallel

A logic to determine whether to use parallel processing. Only be used for tibble dataset.

Details

Convert timeseries to specified frequency by refrequencing date index. Optionally provide filling method to pad/backfill missing values. Return original data conformed to a new index with the specified frequency.

ts_asfreq is more appropriate if use original the data at the new frequency.

Value

1
       A converted timeseres

Methods (by class)

See Also

Other utils_timeseries: ts_lag(), ts_resample()


chriszheng2016/zstmodelr documentation built on June 13, 2021, 8:59 p.m.