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.