程序的这一部分需要两个输入:1)用户和2)选择的日期范围会影响所显示的绘图输出。现在,显示的绘图输出仅为空白。我的控制台中没有列出任何错误。
我的csv文件的“日期”列的格式为:03/14/12。
感谢您的帮助或观察。
library(shinydashboard)
library(shiny)
library(ggplot2)
library(gridExtra)
library(dplyr)
library(tidyverse)
library(lubridate)
ui <- dashboardPage(
dashboardHeader(title = "T"),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(
title = "Controls",
selectInput("User",
"User:",
c("All",
unique(as.character(df$User))))
),
box(
dateRangeInput("dates",
"Date range",
start = "01-01-2018",
end = "06-25-2018")
),
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Plot", plotOutput("plot")
)
)
)
)
)
)
server <- function(input, output){
df <- read.csv(file = "c:/T/T/T.csv", header = TRUE, sep = ",")
df$Date <- as.Date(df$Date)
begin<- reactive({input$dates[1]})
finish<- reactive({input$dates[2]})
output$plot <- renderPlot({
df.filtered <- df %>%
filter(df$User == input$User) %>%
filter(Date >= begin(), Date <= finish())
req(df.filtered)
df.filtered %>%
ggplot(aes(DfM, SvM, colour = User)) +
geom_point(show.legend = FALSE) +
directlabels::geom_dl(aes(label = User), method = "smart.grid")
shinyApp(ui, server)