Home > OS >  How to superimpose two ts objects with two different axes with ts.plot in R?
How to superimpose two ts objects with two different axes with ts.plot in R?

Time:06-12

library(tseries)
library(readxl)

data = read_excel(.......)

#Create tseries

equity = ts(data$EQUITY, start = c(2015,01,01), end = c(2020,01,01), frequency = 12)
cci = ts(data$CCI, start = c(2015,01,01), end = c(2020,01,01), frequency = 12)

#Plot the two series together

ts.plot(equity, cci, lty = c(1:2))

This code returns the following chart: screenshot

  • Related