I have a simple shiny app below in which I want to be able to select the data range based on the choice of "INT" or "DOM" from the checkbox group. But I cannot make it work. I get an error when im trying to use min and max. I recreated my data frame with:
OriginId = c("INT", "DOM", "INT","DOM")
RequestedDtTm = c("2017-01-16 16:43:33
", "2017-01-17 16:43:33
", "2017-01-18 16:43:33
","2017-01-19 16:43:33")
testdata = data.frame(OriginId,RequestedDtTm)
## ui.R ##
library(shinydashboard)
dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody()
)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
## Sidebar content
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Change View", tabName = "widgets", icon = icon("th"))
)
),
## Body content
dashboardBody(
tabItems(
# First tab content
# Second tab content
tabItem(tabName = "widgets",
fluidRow(
box(title="Histogram 1",width = 12,
column(4,
checkboxGroupInput("checkGroup2", label = h3("Checkbox group"),
choices = list("Show Domestic" = "DOM", "Show International" = "INT"),
selected = "DOM")
),
column(4,
uiOutput("dt1")
),
column(4,
numericInput("num", label = h3("Numeric input"), value = 1)
)
))
)
)
)
)
#server.r
server <- function(input, output) {
output$dt1<-renderUI({
dateRangeInput('dateRange',
label = 'Date range',
start = min(subset(testdata[,2],testdata$OriginId %in% input$checkGroup2)), end = max(subset(testdata[,2],testdata$OriginId %in% input$checkGroup2))
)
})
}