[R] Need help to fix the max date filter problem in the date input
Biplab Nayak
b|p|@bn1 @end|ng |rom gm@||@com
Mon Jun 7 19:03:18 CEST 2021
Hi All,
I Need a bit of help to fix the code.
Code:
library(readr)
library(shiny)
ttclasses <- read_csv("ttclasses.csv")
#Filter data
library(stringr)
library(dplyr)
ttclasses <-ttclasses %>%
filter(str_detect(assessment, "Assignment"))
ttclasses <-ttclasses %>%
filter(str_detect(name, "Name"))
##Remove NA values.
library(tidyverse)
ttclasses <-ttclasses %>% drop_na("score")
#Convert to factor
ttclasses$assessment <- as.factor(ttclasses$assessment)
ttclasses$due_date = as.Date(ttclasses$due_date, format = "mm/dd/yy")
##ttclasses$name <- as.factor(ttclasses$name)
# Define UI ----
ui <- fluidPage(
# App title ----
titlePanel("Assessment Dashboard"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
# Input: Selector for variable to plot the grades for the selected
assignment ----
selectInput("assessment", "Assessment:",
c("Assignment 1" = "Assignment 1",
"Assignment 2" = "Assignment 2",
"Assignment 3" = "Assignment 3",
"Assignment 4" = "Assignment 4",
"Assignment 5" = "Assignment 5")),
selectInput("name", "Name:",
ttclasses[,2]),
dateRangeInput("due_date",
"Due-Date:",start = max(ttclasses$due_date) ,
separator = " - ")
),
# Main panel for displaying outputs ----
mainPanel(
# Output: Plot of the requested variable against grade ----
plotOutput("gradePlot")
)
)
)
# Define server logic to plot ----
server <- function(input, output) {
output$gradePlot <- renderPlot({
grade_ad = input$assessment
boxplot(ttclasses$score[ttclasses$assessment==grade_ad],
frame.plot=FALSE, horizontal=TRUE, col="magenta", main=grade_ad)
ttclasses <-ttclasses %>%
filter(ttclasses$due_date >= input$due_date[1] & ttclasses$due_date
<= input$due_date[2])
})
}
# Create Shiny app ----
shinyApp(ui, server)
Thanks & Regards
[[alternative HTML version deleted]]
More information about the R-help
mailing list