ts_resample: Frequency Conversion Function of Resamping timeseries

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

View source: R/utils-timeseries.R

Description

Generic function to convert timeseries to specified frequency by resampling date 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
26
27
28
ts_resample(
  ts_dataset,
  freq_rule = c("day", "month", "quarter", "year"),
  fillna_method = c("nfill", "ffill", "bfill"),
  agg_fun = mean,
  ...
)

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

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

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.

agg_fun

Function to aggregate values of group data for new timestamp, default setting is mean.

...

Arguments passed to agg_fun.

date_index_field

Name of date index field of ts_df for resample, 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 resampling date index. Optionally provide filling method to pad/backfill missing values. Return aggregating data conformed to a new index with the specified frequency.

ts_resample is more appropriate if an operation, such as summarization, is necessary to represent the data at the new frequency.

Value

1
      A converted timeseres.

Methods (by class)

See Also

Other utils_timeseries: ts_asfreq(), ts_lag()


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