Hello, I need to put 2 or more different time series to one plot for comparison each other. The problem is that the time series are irregular, moreover the time lenghts and periods are not the same. Is there a way to manage it in R? Many thanks for any hint and advice in advance Tomas
plot.zoo and xyplot.zoo in the zoo package can both do that: library(zoo) z <- zoo(c(21, 34, 33, 41, 39, 38, 37, 28, 33, 40), as.Date(c("1992-01-10", "1992-01-17", "1992-01-24", "1992-01-31", "1992-02-07", "1992-02-14", "1992-02-21", "1992-02-28", "1992-03-06", "1992-03-13"))) # z and lag(z) have different spans and are irregular zz <- merge(z, lag(z)) # same screem plot(zz, screen = 1) # different screens plot(zz) # similar but using zoo's xyplot lattice method library(lattice) xyplot(zz, screen = 1) xyplot(zz) Read the three vignettes that come with zoo and the help files. On Fri, Oct 9, 2009 at 12:18 PM, Tomas Lanczos <lanczos at fns.uniba.sk> wrote:> Hello, > > I need to put 2 or more different time series to one plot for comparison > each other. The problem is that the time series are irregular, moreover > the time lenghts and periods are not the same. Is there a way to manage > it in R? > > Many thanks for any hint and advice in advance > > Tomas > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
> Date: Fri, 09 Oct 2009 18:18:05 +0200 > From: Tomas Lanczos <lanczos at fns.uniba.sk> > Sender: r-help-bounces at r-project.org > Precedence: list > > Hello, > > I need to put 2 or more different time series to one plot for comparison > each other. The problem is that the time series are irregular, moreover > the time lenghts and periods are not the same. Is there a way to manage > it in R?The function plot(), maybe...? You need to have both series in a single mts object. Look also at the argument plot.type... HTH, Giovanni> > Many thanks for any hint and advice in advance > > Tomas > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- Giovanni Petris <GPetris at uark.edu> Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/