[R] ts.plot

Gabor Grothendieck ggrothendieck at gmail.com
Sun Jul 6 23:00:51 CEST 2008


On Sun, Jul 6, 2008 at 3:36 PM, threshold <r.kozarski at gmail.com> wrote:
>
> Hi, my question concerns the following (guess) easy case. I have daily data
> over 5-year period say
> 1990    17.24
> 1990    18.19
> 1990    19.22
> .
> .
> 1991    20.11
> 1991    20.26
> 1991    22.2
> .
> .
> 1994    20.05
> 1994    24.64
> 1994    26.34
> and I want to make ts.plot of the 2nd column with respect to year of
> occurrence (1st col) at axis X. Could you please give me a hint how to do
> it? I really appreciate any help
>

Assuming from your post that the series are all in one big data frame like this:

DF <- structure(list(V1 = c(1990L, 1990L, 1990L, 1991L, 1991L, 1991L,
1994L, 1994L, 1994L), V2 = c(17.24, 18.19, 19.22, 20.11, 20.26,
22.2, 20.05, 24.64, 26.34)), .Names = c("V1", "V2"), class =
"data.frame", row.names = c(NA, -9L))
DF

ser <- do.call(cbind, tapply(DF$V2, DF$V1, ts))
ts.plot(ser, col = 1:nrow(ser), type = "o")



More information about the R-help mailing list