I would like to compare the values of two different variables in time.
For example, having two datasets:
dataset1(Date, value)
and
dataset2(Date, value)
In order to plot just first, we can execute the following:
x.Date <- as.Date(dataset1$Date)
x <- zoo(dataset1$Value, x.Date)
plot(x)
To the same window I would like to add (dataset2$value, dataset2$Date), and by chance set the different color.
the values dataset1$Date and dataset2$Date are not neccessary the same (some days might overlap and some not), for example dataset1$Date might contain (dec01, dec02, dec03, dec05) and dataset2$Date (dec02, dec03, dec06).
Does anyone know how to plot two (or several) time plots in the same window?
There are several options. Here are three options working with
zooobjects.If you are plotting regular
tsobjects, you can also explorets.plot: