regex of my data frame:
library(tidyverse)
game_date <- as.Date(c('2014-10-01', '2014-10-02', '2014-10-02',
'2014-10-03', '2014-10-03', '2014-10-03',
'2014-10-04', '2014-10-04', '2014-10-04'))
t1 <- c('LDN', 'PBO', 'BAR',
'BAR', 'BEL', 'LDN',
'BAR', 'PBO', 'GUE')
t2 <- c('GUE', 'BEL', 'SUD',
'GUE', 'PBO', 'KIT',
'LDN', 'NB', 'BEL')
df <- data.frame(game_date, t1, t2)
My goal is to create two columns that produce either "rested", "fatigue" or "tired" based on if the string appears in previous days.
Conditions:
rested = does not appear in any row defined by game_date -1
fatigue = string appears in any row defined by game_date-1
tired = string appears in any row defined by game_date-1 & game_date-2
Here is picture of ultimate goal.
Thank you in advance,