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
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
There is a new FAQ #13 in the zoo-faq vignette in the development version of the zoo package which illustrates several approaches to this (all of which work in the current version of zoo as well). See: http://pages.citebite.com/l2m2b3i4k5fnv On Mon, Mar 15, 2010 at 1: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. >