Learn R Programming

tsbox (version 0.4.1)

ts_scale: Scale and Center Time Series

Description

Subtract mean (sum(x)/n) and divide by standard deviation (sqrt(sum(x^2)/(n-1))). Based on base::scale().

Usage

ts_scale(x, center = TRUE, scale = TRUE)

Value

a ts-boxable object of the same class as x, i.e., an object of class ts, xts, zoo, zooreg, data.frame, data.table, tbl, tbl_ts, tbl_time, tis, irts or timeSeries.

Arguments

x

ts-boxable time series, an object of class ts, xts, zoo, zooreg, data.frame, data.table, tbl, tbl_ts, tbl_time, tis, irts or timeSeries.

center

logical

scale

logical

Examples

Run this code
# \donttest{
ts_plot(ts_scale((ts_c(airmiles, co2, JohnsonJohnson, discoveries))))
ts_plot(ts_scale(ts_c(AirPassengers, DAX = EuStockMarkets[, "DAX"])))
# }

Run the code above in your browser using DataLab