Dear R Community,

I wish to create 5 preceding dates from the date variable by ID. How
could I create such dates? The code should consider leap year.

Thanks

Sample data follows:


structure(list(id = 1:12, date = structure(c(9L, 6L, 11L, 8L,
7L, 5L, 4L, 3L, 12L, 1L, 10L, 2L), .Label = c("01feb2003", "03mar2008",
"04feb2008", "07jul1991", "07jun2010", "13feb2005", "18dec1991",
"22sep2005", "27apr1993", "29jan2009", "29may2002", "31jan2005"
), class = "factor"), case = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L)), .Names = c("id", "date", "case"), class =
"data.frame", row.names = c(NA,
-12L))

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to