I have the following dataframe that I am importing into a Shiny app:
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 (-115)", "1300.5 (-115)", "7.5 (115)",
"7.5 (-140)", "31.5 (-120)", "31.5 (100)", "4050.5 (-110)",
"4050.5 (-110)", "750.5 (-110)", "750.5 (-120)"), BetMGM = c("-",
"-", "-", "-", "-", "-", "-", "-", "699.5 (-125)", "699.5 (-105)"
), FanDuel = c("-", "-", "-", "-", "30.5 (-112)", "30.5 (-112)",
"3950.5 (-112)", "3950.5 (-112)", "750.5 (-112)", "750.5 (-112)"
), Caesars = c("-", "-", "-", "-", "30.5 (-115)", "30.5 (-115)",
"4000.5 (-115)", "4000.5 (-115)", "775.5 (-115)", "775.5 (-115)"
)), row.names = c(NA, -10L), class = c("tbl_df", "tbl", "data.frame"
))
What I want to do is make it so that the lowest value (of the numbers not in parentheses) in columns 3-6 is highlighted in green for each row of data. The complications here are two-fold: 1) there isn't always a value in each of the columns, and 2) I just need to evaluate the numbers outside of the parentheses.
Here is a basic outline of the Shiny app as it stands:
library(shiny)
library(tidyverse)
library(dplyr)
library(reactable)
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 (-115)", "1300.5 (-115)", "7.5 (115)",
"7.5 (-140)", "31.5 (-120)", "31.5 (100)", "4050.5 (-110)",
"4050.5 (-110)", "750.5 (-110)", "750.5 (-120)"), BetMGM = c("-",
"-", "-", "-", "-", "-", "-", "-", "699.5 (-125)", "699.5 (-105)"
), FanDuel = c("-", "-", "-", "-", "30.5 (-112)", "30.5 (-112)",
"3950.5 (-112)", "3950.5 (-112)", "750.5 (-112)", "750.5 (-112)"
), Caesars = c("-", "-", "-", "-", "30.5 (-115)", "30.5 (-115)",
"4000.5 (-115)", "4000.5 (-115)", "775.5 (-115)", "775.5 (-115)"
)), row.names = c(NA, -10L), class = c("tbl_df", "tbl", "data.frame"
))
ui <- fluidPage(
reactableOutput("odds_table")
)
server <- function(input, output) {
output$odds_table <- renderReactable({
reactable(final_odds)
})
}
# Run the application
shinyApp(ui = ui, server = server)