different time series in one plot

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

different time series in one plot

lanczos-2
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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: different time series in one plot

Gabor Grothendieck
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 <[hidden email]> 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
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: different time series in one plot

Giovanni Petris
In reply to this post by lanczos-2

> Date: Fri, 09 Oct 2009 18:18:05 +0200
> From: Tomas Lanczos <[hidden email]>
> Sender: [hidden email]
> 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
>
> ______________________________________________
> [hidden email] 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  <[hidden email]>
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

______________________________________________
[hidden email] 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.