[R] plot question
Gabor Grothendieck
ggrothendieck at myway.com
Wed Nov 17 03:31:55 CET 2004
Apoian, Zack <Zack.Apoian <at> sac.com> writes:
> Say y and z are two time series (functions of "date"). What is the R
> command to plot y and z together on a graph with "date" on the x-axis?
There are several time series classes (ts, zoo in zoo, irts
in tseries, its in its, timeDate in fBasics) and its also possible
to plot a numeric vector against a vector of dates.
Here is an example using zoo which also illustrates the case
where the times are not the same:
library(zoo)
# -- test data --
# y is over today and next 4 days.
# z over today and next 9 days.
y <- zoo(11:15, Sys.Date() + 0:4)
z <- zoo(21:30, Sys.Date() + 0:9)
plot(merge(y,z), plot.type = "single", ylim = range(c(y,z)),
col = c("green", "red"))
More information about the R-help
mailing list