I am working on a large dataset that contains data on travel behavior over a weekly period. During the week, people filled out a journal of individual trips that they made during that week. Individuals are identified by a unique identification number (ID). What I want to do is select two days of daily data (which may contain one or more trips) from the weekly data available for each unique identifier, and put this in a new data frame. An example data frame is described in detail below:
Df1 <- data.frame(ID = c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3),
date = c("1st Nov", "1st Nov", "3rd Nov", "4th Nov","4th Nov","5th Nov","2nd Nov", "2nd Nov", "3nd Nov", "4th Nov","5th Nov","5th Nov","2nd Nov", "2nd Nov", "3nd Nov", "4th Nov","5th Nov"))
Any help on the above would be greatly appreciated.
Many thanks,
Katie
source
share