Pick (and optionally rename) series from multiple time series.

ts_pick(x, ...)

Arguments

x

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

...

character string(s), names of the series to be picked. If arguments are named, the series will be renamed.

Value

a ts-boxable time series, with the same class as the input.

Examples

# Interactive use
ts_plot(ts_pick( EuStockMarkets, `My Dax` = "DAX", `My Smi` = "SMI" ))
head(ts_pick(EuStockMarkets, c(1, 2)))
#> Time Series: #> Start = c(1991, 130) #> End = c(1991, 135) #> Frequency = 260 #> DAX SMI #> 1991.496 1628.75 1678.1 #> 1991.500 1613.63 1688.5 #> 1991.504 1606.51 1678.6 #> 1991.508 1621.04 1684.1 #> 1991.512 1618.16 1686.6 #> 1991.515 1610.61 1671.6
head(ts_pick(EuStockMarkets, `My Dax` = 'DAX', `My Smi` = 'SMI'))
#> Time Series: #> Start = c(1991, 130) #> End = c(1991, 135) #> Frequency = 260 #> My Dax My Smi #> 1991.496 1628.75 1678.1 #> 1991.500 1613.63 1688.5 #> 1991.504 1606.51 1678.6 #> 1991.508 1621.04 1684.1 #> 1991.512 1618.16 1686.6 #> 1991.515 1610.61 1671.6
# Programming use to.be.picked.and.renamed <- c(`My Dax` = "DAX", `My Smi` = "SMI") head(ts_pick(EuStockMarkets, to.be.picked.and.renamed))
#> Time Series: #> Start = c(1991, 130) #> End = c(1991, 135) #> Frequency = 260 #> My Dax My Smi #> 1991.496 1628.75 1678.1 #> 1991.500 1613.63 1688.5 #> 1991.504 1606.51 1678.6 #> 1991.508 1621.04 1684.1 #> 1991.512 1618.16 1686.6 #> 1991.515 1610.61 1671.6