[R] Need help to fix the max date filter problem in the date input
Bert Gunter
bgunter@4567 @end|ng |rom gm@||@com
Tue Jun 8 18:07:19 CEST 2021
I do not wish to be involved in this thread other than to note that you
were, I believe, asked not to post in HTML. And because you did, you will
find that "Bold" highlighting does not exist in your text below. I have no
idea whether that matters for your query or not, but there it is.
Bert Gunter
On Tue, Jun 8, 2021 at 8:13 AM Biplab Nayak <biplabn1 using gmail.com> wrote:
> Hi Rui,
>
> Please find the code(bold) below I was trying to do to achieve the
> achieve:But somehow its not working.
> 1.Order assessment based on the latest due date so select input
> automatically show the order of assessment name.
> 2.Filter based on the one name or multiple names in the select input
>
> library(tidyverse)
> #library(stringr) # attached with tidyverse
> #library(readr)
> library(shiny)
> library(dplyr)
>
> ttclasses <- read_csv("~/tmp/ttclasses.csv")
>
> #Filter data
> ttclasses <-ttclasses %>%
> filter(str_detect(assessment, "Assignment"))
>
> # With the attached data this filter
> # removes all rows so I have
> # commented it out
>
>
> *ttclasses <-ttclasses %>% filter(str_detect(name, "Name"))*
> ##Remove NA values.
> ttclasses <-ttclasses %>% drop_na("score")
>
> *## Sort assessment based on max due_date*
> * ttclasses <- ttclasses [order( - due_date, assessment ),]*
>
> #Convert to factor
> ttclasses$assessment <- factor(ttclasses$assessment)
>
> # please see the formats in help("strptime")
> ttclasses$due_date <- as.Date(ttclasses$due_date, format = "%m/%d/%y")
> *ttclasses$name <- 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
> Biplab Nayak
>
> On Tue, Jun 8, 2021 at 7:08 AM Rui Barradas <ruipbarradas using sapo.pt> wrote:
>
> > Hello,
> >
> > Please cc the list.
> > R-Help is not a code writing service, it's a mailing list for doubts on
> > R code. I'm sorry but without answers to the below questions I am not
> > going to answer.
> >
> >
> > What have you tried? What went wrong?
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> > Às 04:01 de 08/06/21, Biplab Nayak escreveu:
> > > Hi Rui,
> > >
> > > It's working fine. Now I need to achieve the following:
> > >
> > > * Default view of most recent distributions by most recent assignment
> > > due date
> > >
> > > * Filter by one or more students
> > >
> > > Please help
> > >
> > > Thanks & Regards
> > > Biplab Nayak
> > >
> > > On Mon, Jun 7, 2021 at 6:51 PM Rui Barradas <ruipbarradas using sapo.pt
> > > <mailto:ruipbarradas using sapo.pt>> wrote:
> > >
> > > Hello,
> > >
> > > Thanks for the data.
> > > There were some, not many, bugs that I have corrected below.
> > >
> > >
> > >
> > > library(tidyverse)
> > > #library(stringr) # attached with tidyverse
> > > #library(readr)
> > > library(shiny)
> > >
> > > ttclasses <- read_csv("~/tmp/ttclasses.csv")
> > >
> > > #Filter data
> > > ttclasses <-ttclasses %>%
> > > filter(str_detect(assessment, "Assignment"))
> > >
> > > # With the attached data this filter
> > > # removes all rows so I have
> > > # commented it out
> > > #ttclasses <-ttclasses %>%
> > > # filter(str_detect(name, "Name"))
> > >
> > > ##Remove NA values.
> > > ttclasses <-ttclasses %>% drop_na("score")
> > >
> > > #Convert to factor
> > > ttclasses$assessment <- factor(ttclasses$assessment)
> > >
> > > # please see the formats in help("strptime")
> > > ttclasses$due_date <- as.Date(ttclasses$due_date, format =
> > "%m/%d/%y")
> > > ##ttclasses$name <- 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)
> > >
> > >
> > >
> > > Hope this helps,
> > >
> > > Rui Barradas
> > >
> > > Às 18:03 de 07/06/21, Biplab Nayak escreveu:
> > > > 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]]
> > > >
> > > > ______________________________________________
> > > > R-help using r-project.org <mailto:R-help using r-project.org> mailing list
> > > -- To UNSUBSCRIBE and more, see
> > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > <https://stat.ethz.ch/mailman/listinfo/r-help>
> > > > PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > > <http://www.R-project.org/posting-guide.html>
> > > > and provide commented, minimal, self-contained, reproducible
> code.
> > > >
> > >
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list