Description Usage Arguments Details Value Methods (by class) See Also
View source: R/utils-timeseries.R
Generic function to convert timeseries to specified frequency by resampling date index
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"),
...
)
|
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. |
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.
1 | A converted timeseres.
|
tbl_df
: Resamping timeseries of tibble dataset
timeSeries
: Resamping timeSeries of timeSeries dataset
Other utils_timeseries:
ts_asfreq()
,
ts_lag()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.