简体   繁体   中英

Overlying time series of two datasets (with two variables in each) in one window by using plot.ts in R

I do have two data sets with values of two variables (a and b) in each, ie

           data<-data.frame(a=c(2,3,4,5), b=c(2,3,5,6))
           data1 <- data.frame(a=c(2.2,3.4,4.5,5.6), b=c(2.3, 3.5,5.4,6.5))

I may plot times series of both variables in two separate windows by applying "plot.ts":

           plot.ts(data); 
           plot.ts(data1)

But the question is how can I can get the same plot (by applying "plot.ts") but in one window? That is, in one window would like to have two graphs, where in each would be compared a and b from different data sets, respectively. Thank you in advance.

请尝试以下操作:

ts.plot(data, col = 1:2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM