Я пытаюсь сделать приборную панель в R Shiny. Но я продолжаю получать ошибку и не могу понять, как решить эту проблему.
Ошибка:
data
должен быть фреймом данных или другим объектом, допускаемым fortify()
, а не логическим вектором
Может ли кто-либо пожалуйста помоги? Спасибо!
library(shiny)
library(shinydashboard)
library(tidyverse)
library(lubridate)
KPI1_shiny <- structure(list(J = c("2017", "2017", "2017", "2017", "2017", "2017"), M = c("01", "02", "03", "04", "05", "06"), Ordermaand = structure(c(17167, 17198, 17226, 17257, 17287, 17318), class = "Date"), AantalProducten = c(706L, 644L, 727L, 724L, 787L, 1018L)), row.names = c(NA, 6L), class = "data.frame")
ui <- dashboardPage(
dashboardHeader(title = "Dashboard by: Bjorn"),
dashboardSidebar(
sidebarMenu(
menuItem("KPI1", tabName = "KPI1", icon = icon("th")),
menuItem("KPI2", tabName = "KPI2 | ", icon = icon("th")),
menuItem("Dashboard", tabName = "KPI7", icon = icon("chart-bar")),
menuItem("Widgets", tabName = "KPI9", icon = icon("th")))
),
dashboardBody(
tabItems(
# KPI 1 Aantal verkochte producten binnen een tijdsperiode----------------------------------------------------------------------------------------------------
tabItem(tabName = "KPI1",
fluidRow(
box(title = "Begindatum",
selectInput(
inputId = "Beginjaar", label = "Beginjaar:",
list("2017", "2018"
)),
selectInput(inputId = "Beginmaand", label = "Beginmaand",
list("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12")
)),
box(title = "Einddatum",
selectInput(
inputId = "Eindjaar", label = "Eindjaar:",
list("2017", "2018"
)),
selectInput(inputId = "Eindmaand", label = "Eindmaand",
list("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12")
)),
box(plotOutput("iPlot1"))
)
)
)
))
server <- function(input, output) {
v <- reactiveValues(value = NULL)
observe({
v$Begin <- make_date(input$Beginjaar, input$Beginmaand)
v$Eind <- make_date(input$Eindjaar, input$Eindmaand)
})
output$iPlot1 <- renderPlot({KPI1_shiny %>% filter(between(Ordermaand, v$Begin, v$Eind) %>%
ggplot(aes(x = Ordermaand, y = AantalProducten, group = 1))
)})
}
shinyApp(ui, server)