Your request seems bizarre to me. If you really want to ignore the actual time
intervals, just do your analysis without the actual dates.
If you just want forward-looking time intervals, then put them in the correct
index locations.
?diff
c(diff(DF$DATE),1)
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Geoffrey Smith <gps@asu.edu> wrote:
Hello, I have some unbalanced panel data that is measured on weekdays only
(i.e., excluding Saturday and Sunday). I would like to get the number of days
between dates such that the number of days between a Friday and a Monday is 1
(and not 3). Here is some code to illustrate my problem:
library('Hmisc'); DATE <-
as.Date(c('2011-05-18','2011-05-19','2011-05-20','2011-05-23','2011-05-24','2011-05-25'),
'%Y-%m-%d'); TEMP <- c(100,105,110,95,90,95); DAYS <-
weekdays(DATE); DF <- data.frame(DATE, TEMP, DAYS); DF; DF$DAYS.BETWEEN <-
DF$DATE - Lag(DF$DATE); DF; Essentially, I want to get it so the variable
DAYS.BETWEEN is equal to 1 for observation number 4. Any ideas? Thank you. Geoff
[[alternative HTML version
deleted]]_____________________________________________
R-help@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.
[[alternative HTML version deleted]]