I currently have baseball data and hoping to filter a data frame to the games a player has played in during the week prior and after his birthday. Having trouble filtering just by the month and day.
Code:
#create variable that is the month-day of the start of the 2017 season
start_2017 = format(as.Date(seasons_g_2017[seasons_g_2017$name == 2017,]$starts_on), "%m%d")
#create variable that is the month-day of the end of the 2017 season
end_2017 = format(as.Date(seasons_g_2017[seasons_g_2017$name == 2017,]$ends_on), "%m%d")
#create column in players_data that shows month-day of the player's birthday
players_data$birth_date_filter = as.Date(players_data$birth_date,"%m%d")
#filter players_data to only players who have a birthday during the actual season
players_data = players_data[players_data$birth_date_filter >= start_2017 &
players_data$birth_date_filter <= end_2017,]