[R] gaps in time series

Henrique Dallazuanna wwwhsd at gmail.com
Mon Mar 15 18:15:59 CET 2010


Try this:

x
          V1 V2
1 2010-03-01  9
2 2010-03-03 17
3 2010-03-04  2
4 2010-03-05  9
5 2010-03-07  3

rng <- range(as.Date(x$V1))
with(merge(data.frame(V1 = seq(rng[1], rng[2], by = 'day')),
      x, all = TRUE), aggregate(V2, list(V1), FUN = sum, na.rm = TRUE))



On Mon, Mar 15, 2010 at 2:02 PM, Joe Calderon <calderon.joe at gmail.com> wrote:
> hello *, im new to the list (and R in general), i have a problem that
> im hoping someone can help me solve. i have data that i want to turn
> into a time series per day,
>
> ex.
> 2010-03-01   9
> 2010-03-03   17
> 2010-03-04   2
> 2010-03-05   9
> 2010-03-07   3
>
> is there an easy way to fill in the gaps for the missing days?
>
>
> thx much
>
>
> --joe
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list