Hello everybody,
I need your help please : I have a dataframe named data_test, you can reproduce it with these lines :
PC<-c('001','002','003','004','005','006','007','008','009','010')
A<-c('2','2','1','1','2','0','2','0','1','0')
B<-c('0','2','0','0','1','0','0','0','1','0')
C<-c('1','0','0','0','2','2','0','0','0','1')
NB_CARS<-c('1','3','1','1','0','2','1','3','2','2')
data_test <- data.frame(PC, A, B, C, NB_CARS)
And I have three linked chekboxGroupInputs named "variable1", "variable2" and "variable3". When I check some of these chekboxGroupInputs, the number of matching rows is updated. But I would like to insert a reactive SelectInput to show the resulting number of cars based on the "NB_CARS" variable, and I don't manage to do that. Could you please help me ? Thanks much.
This is my code :
ui <- fluidPage(
fluidRow(
column(3,
checkboxGroupInput("variable1", "Occurences of column A :",
c("Yes (1)" = "1",
"No (2)" = "2",
"Perhaps (0)" = "0")),
checkboxGroupInput("variable2", "Occurences of column B :",
c("Yes (1)" = "1",
"No (2)" = "2",
"Perhaps (0)" = "0")),
checkboxGroupInput("variable3", "Occurences of column C :",
c("Yes (1)" = "1",
"No (2)" = "2",
"Perhaps (0)" = "0"))),
column(3,
tableOutput("data")),
column(3,
textOutput("result"))
)
)
server <- function(input, output, session) {
result <- 0
df1 <- reactive({
filter(data_test,
(is.null(input$variable1) | A %in% input$variable1),
(is.null(input$variable2) | B %in% input$variable2),
(is.null(input$variable3) | C %in% input$variable3))
})
output$result <- renderText(paste("Number of occurences = ", nrow(df1())))
output$data <- renderTable({df1()})
}
shinyApp(ui, server)