I have a dataset which contains a list of dates and columns containing R and S. R indicates the regular and S indicates for special
date <- c('01/01', '01/02', '01/03', '01/04', '01/05', '01/06', '01/07', '01/08', '01/09')
day <- c('S', 'S', 'R', 'S', 'R', 'S', 'R', 'R', 'S')
data <- data.frame(date, day)
It looks like this:
date . . . day
01/01. . . S
01/02. . . S
01/03. . . R
01/04. . . S
01/05. . . R
01/06. . . S
01/07. . . R
01/08. . . R
01/09. . . S
....
I'm trying to add a column now to indicate how many "special" days are coming up in the next 7 days, based on the date. For example, for 01/01,
I want to know how many cells contain Special days in the upcoming 7 days and store then in a new column. For example, 01/01 should give me 3, from 01/02 to 01/08 there are 'S' days (01/02, 01/04, and 01/06).
I am thinking of using mutate but I am not sure will it work or not. Can anyone help me solve it?