[R] plot two time series with different length and different starting point in one figure.
dwinsemius at comcast.net
Tue Jan 22 20:34:14 CET 2013
On Jan 22, 2013, at 7:07 AM, Yuan, Rebecca wrote:
> I do have two different time series A and B, they are different in length and starting point. A starts in Jan, 2012 and ends in Dec, 2012 and B starts in March, 2012 and ends in Nov, 2012.
> How can I plot those two series A and B in the same plot? I.E., from Jan. 2012 - Feb, 2012, it would have one data point from A and from Mar, 2012-Nov, 2012, it would have two data points from A and B, and in December 2012, it would have one data point from A.
You could set the xlim argument to c( min(timeA, timeB), max(timeA, timeB) ) in the `plot` of either of the series and then use `lines` for the other series, perhaps with a different color argument.
Alameda, CA, USA
More information about the R-help