I am trying to add a drop down menu to manipulate my dataframe.
For example,
Assume my df has the columns - a1 a2 a3 b1 b2 c1 c2 c3
and I wanted to add a dropdown menu with choices = list("All", "a", "b", "c") that would filter the table to include all columns, columns that begin with a or begin with b an so on.
Not sure how to go about this. Open to either creating new df's that can be called when a choice is selected or having the df manipulated based on the choice.
Here is some sample code (not my real code):
library(shiny)
shinyUI(fluidPage(
titlePanel("x"),
sidebarLayout(
sidebarPanel(
selectInput(inputId = "x",
choices = list("All", "a", "b", "c"))
),
mainPanel(
dataTableOutput('x')
)
)
))
#dfa <- data.frame(select(df, starts_with("a")))
#dfb <- data.frame(select(df, starts_with("b")))
#dfc <- data.frame(select(df, starts_with("c")))
shinyServer(function(input, output) {
output$x = renderDataTable({
?????
})
})