I am not new to R but I am new to R-Shiny and am trying to build an app that queries data (I do not know if there is a better term to describe what I am trying to do.)
Essentially, the app has a series of questions using inputs in the UI that is then supposed to narrow down the data to match the user's specific preferences. I have been referring to it as a "buzzfeed quiz" because that the most non-technical thing I can think of that does the same thing. Regardless, I may have bitten off more than I can chew because I am having trouble getting the syntax correct in my code to get it to query even one question. I think once I get one to work I should be able to do the other questions.
UI <-fluidpage(
tabPanel(
"Find My AVF",
headerPanel("What Your AVF Match?"),
radioButtons(inputId = "q1", label = h3("How many people are in your household?"),
choices = list("1 to 2" = 1, "3 to 5" = 2, "6 to 7" = 3, "8" = 4, "9 or more" = 5),
selected = 1),
actionButton("execute", label = "Find my Perfect Car!"),
tableOutput("resulttable")
)
server <- function(input,output){
q1a <- reactive({
if (input$q1 == "1 to 2"){
q1dat <- Seats < 6
} else if (input$q1 == "3 to 5") {
q1dat <- Seats > 2 & Seats < 6
} else if (input$q1 == " 6 to 7") {
q1dat <- Seats > 5
} else if (input$q1 == "8"){
q1dat <- Seats > 7
} else if (input$q1 == "9 or more") {
q1dat <- Seats = 9
}
})
result <- eventReactive(input$execute, {
output$resulttable <- renderTable(q1a
)
})
}
I was hoping to simply get R to reduce my dataset down to based on what the user clicks on in the UI and what it is attached to in the code behind it. If the person selects 3 to 5 people, I want it to get the dataset down to only vehicles that have between two and six seats. Currently, the app does nothing. The UI works fine, but the action button does not perform any actions.