[R] Discretizing data rows into regular intervals
Linh Tran
Tranlm at berkeley.edu
Sun Apr 3 03:31:55 CEST 2011
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
More information about the R-help
mailing list