Pick (and optionally rename) series from multiple time series.
ts_pick(x, ...)
x | ts-boxable time series, an object of class |
---|---|
... | character string(s), names of the series to be picked, or integer, with positions. If arguments are named, the series will be renamed. |
a ts-boxable time series, with the same class as the input.
# Interactive use # \donttest{ ts_plot(ts_pick( EuStockMarkets, `My Dax` = "DAX", `My Smi` = "SMI" ))#> 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#> 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