I have the following dataframe:
final_odds <- structure(list(player_prop = c("Aaron Jones: Rush + Rec Yards",
"Aaron Jones: Rush + Rec Yards", "Aaron Rodgers: Interceptions",
"Aaron Rodgers: Interceptions", "Aaron Rodgers: Pass TDs", "Aaron Rodgers: Pass TDs",
"Aaron Rodgers: Pass Yards", "Aaron Rodgers: Pass Yards", "Adam Thielen: Rec Yards",
"Adam Thielen: Rec Yards"), Side = c("Over", "Under", "Over",
"Under", "Over", "Under", "Over", "Under", "Over", "Under"),
DraftKings = c(1300.5, 1300.5, 7.5, 7.5, 31.5, 31.5, 4050.5,
4050.5, 750.5, 750.5), BetMGM = c(50000, 0, 50000, 0, 50000,
0, 50000, 0, 699.5, 699.5), FanDuel = c(50000, 0, 50000,
0, 30.5, 30.5, 3950.5, 3950.5, 750.5, 750.5), Caesars = c(50000,
0, 50000, 0, 30.5, 30.5, 4000.5, 4000.5, 775.5, 775.5)), row.names = c(NA,
-10L), class = c("tbl_df", "tbl", "data.frame"))
I'm trying to create a function that evaluates columns 3-6 within each row to identify which is the highest if the Side
value is "Under" or the lowest if the Side
value is "Over" and converts those values to a 1 with the rest being a 0.
So, I would want the final dataframe to look like this based on the given dataframe:
Is there a simple function I could write to accomplish this?