[R] Discretizing data rows into regular intervals

From: Linh Tran <Tranlm_at_berkeley.edu>
Date: Sat, 02 Apr 2011 18:31:55 -0700


Hi guys,

I'd like to thank you ahead of time for any help that you can offer me. I'm kind of stuck trying to do this.

I have a data frame with dates and values (note: only two columns shown):

head(test)

        date     value         stop
1     01/02/05     100     12/01/07
2     07/16/05     200     12/01/07
3     12/20/05     150     12/01/07
4     04/01/06     250     12/01/07
5     10/01/06      10     12/01/07

What I need to do is create regularly spaced 3-month intervals (starting with the first observed date) with values that are closest to but recorded after the date created. I would stop at the stop date. So the result would look like:

      new_date   value
1     01/02/05     100
2     04/02/05     100
3     07/02/05     100
4     10/02/05     200
5     01/02/06     150
6     04/02/06     250
7     07/02/06     250
8     10/02/06      10
9     01/02/07      10

etc
etc
etc 10/02/07 --- ## Final obs since next one would be 1/2/08 (after stop date)

Again, I would be extremely grateful for any help.

Thanks,

-linh



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. Received on Sun 03 Apr 2011 - 01:38:37 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 03 Apr 2011 - 10:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive