# [R] ts.data plot

Gabor Grothendieck ggrothendieck at gmail.com
Tue Oct 14 23:46:09 CEST 2008

```Assuming the first observation associated with each year is Jan 1,
the second is Jan 2 and so on we have the following.  as.yearmon
converts the year into a year/month object and as.Date turns that
into Jan 1 of that year.  Then the ave calculation adds 0, 1, ...
to that so we get sequential dates within years.  Then we create
a zoo object whose values are obs and whose times were just
calculated and plot.

names(DF) <- c("year", "obs")
library(zoo)
z <- with(DF, zoo(obs,
as.Date(as.yearmon(1900 + year)) + ave(year, year, FUN = seq_along) - 1))
plot(z)

On Tue, Oct 14, 2008 at 2:11 PM, threshold <r.kozarski at gmail.com> wrote:
>
> Hi, my data consists of 2 columns: one with the 'year' when daily observation
> was recorded, the other one consists these observations 'obs', like the
> following:
>          year obs
> [3014,] 86  26.01
> [3015,] 86  25.66
> [3016,] 86  23.92
> [3017,] 86  23.84
> .
> .
> [3018,] 96  22.65
> [3019,] 96  23.22
> [3020,] 96  23.36
> .
> .
> [3021,] 97  24.55
> [3022,] 97  27.63
> [3023,] 97  27.92
> [3024,] 97  27.37
> [3025,] 97  26.11
> [3026,] 97  26.33
> [3027,] 97  27.19
>
> I want to make a plot of my time series data, where on OX axis we have the
> year(s), on OY axis the daily observations. I will appreciate any help
>
> thanks
> --
> View this message in context: http://www.nabble.com/ts.data-plot-tp19979152p19979152.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help