## app.R ##
library(shiny)
library(shinydashboard)
library(ggplot2)
library(data.table)
ui <- dashboardPage(
dashboardHeader(title = "Smart Survey Insights"),
dashboardSidebar(
dateRangeInput("dateRange", "Please choose date", "2017-01-01", NULL),
checkboxInput("comparePreviousPeriod", "Compare to previous period")
),
dashboardBody(
fluidRow(
column(12, plotOutput("boxPlot")),
)
)
)
server <- function(input, output) {
mydata <- data_frame(ended = c("14/11/2016 13:37", "14/11/2016 13:37",
"14/11/2016 13:47", "14/11/2016 13:51", "14/11/2016 13:51"),
task = c("Find licensing information", "Sign in to my existing account",
"Sign in to my existing account", "Bus registrations", "Make changes to my existing Operator’s Licence"), taskLevelOfDifficulty = c("Extremely difficult", "Extremely easy", "Neither easy nor difficult", "Extremely difficult", "Extremely easy"))
mydata <- mydata %>% mutate(ended = as.Date(ended, format = "%Y-%m-%d"))
filteredData <- mydata %>% filter(ended >= input$date_range[1] && mydata$ended <= input$date_range[2])
output$boxPlot <- renderPlot(ggplot(filteredData, aes(taskLevelOfDifficulty))) + geom_bar()
}
shinyApp(ui, server)
我的代码似乎不起作用,问题是我的“已结束”列具有14/11/2016 13:37
格式,而dateRangeInput具有yyyt-mm-dd
格式。我不知道如何将我的图表与dateRangeInput
。