0
votes

I have a reactive shiny which connects to MySQL and renders a data table upon input from the user. In table mytable,

Column A has values - Won or Lost
Column B has values - Won or Lost or Tied
Column C has values - 1 to 9
Column D has values - 0 to 150
Column E has values - 1 or 2

These 4 values are chosen based on the user input. The table mytable has other columns like E and F which do not depend on the user input.

ui <- fluidPage(fluidRow(
column(4,radioButtons("firstorsecond", "First or Second",
choices = c(1: 2),selected='1')),

column(4,radioButtons("anotherselection", "Choose won or lost",
choices = list("Won" = 1, "Lost" = 2),selected='1')),

column(4,radioButtons("result", "Match Result",
choices = list("Won" = 1, "Lost" = 2, "Tied"=3),selected='1')),


column(4,checkboxGroupInput("pos", "Position", 
choices = c(1:9),inline = TRUE)),

column(4,sliderInput("range", "Score Range", min = 0, 
    max = 150,value = c(25,75))
))
)

server <- function(input, output) 
{

 rs=dbSendQuery(mydb,"select A,B,C,D,E,F from mytable where name='abcd'")
 adv_ana=fetch(rs,n=-1)

 dataInput<-reactive({
 **code goes here**
 })
 }

In dataInput<-reactive({}), help me figure out how to get the input value and display a table containing all the columns.

Thanks in advance.

1

1 Answers

0
votes

You can use dplyr::filter to filter rows based on your criteria (untested as I do not have your data):

datainput <- reactive{(
  your_table %>% 
    dplyr::filter(A == input$firstorsecond,
                  B == input$anotherselection,
                  C == input$result,
                  D == input$pos)
})

You may have adapt to your actual inputs, ebcasue I count there 5 inputs while in your description you mention only 4 columns.