Need help to fix the max date filter problem in the date input

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help to fix the max date filter problem in the date input

Biplab Nayak
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Rui Barradas
Hello,

This is not reproducible, we don't have access to ttclasses.csv.
Can you post sample data? Please post the output of

dput(ttclasses)

Or, if it is too big, the output of

dput(head(ttclasses, 20))


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]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Biplab Nayak
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Rui Barradas
In reply to this post by Biplab Nayak
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]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Rui Barradas
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 <[hidden email]
> <mailto:[hidden email]>> 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]]
>      >
>      > ______________________________________________
>      > [hidden email] <mailto:[hidden email]> 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.
>      >
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Biplab Nayak
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Bert Gunter-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Biplab Nayak
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Greg Minshall
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Biplab Nayak
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Biplab Nayak
In reply to this post by Greg Minshall
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Biplab Nayak
In reply to this post by Greg Minshall
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

Jeff Newmiller
In reply to this post by Biplab Nayak
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Need help to fix the max date filter problem in the date input

David Winsemius
In reply to this post by Biplab Nayak

On 6/9/21 5:06 AM, Biplab Nayak wrote:
> Hi Greg,
>
> Please find the objective of the code(bold) and code mentioned below. I was
> trying to do to achieve the below objective but somehow it's not working.


The phrase "somehow not working" is not a useful description of an outcome.

>
> 1.Order assessment based on the latest due date so select input
> automatically shows 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)


I'm pretty sure the tidyverse super-package includes most of the others
with the exception of pkg:shiny (which does not appear to be needed anyway.)

Here's what my version of tidyverse loads:

Imports: broom (>= 0.5.2), cli (>= 1.1.0), crayon (>= 1.3.4), dbplyr (>=
1.4.2), dplyr (>= 0.8.3), forcats (>= 0.4.0),
              ggplot2 (>= 3.2.1), haven (>= 2.2.0), hms (>= 0.5.2), httr
(>= 1.4.1), jsonlite (>= 1.6), lubridate (>=
              1.7.4), magrittr (>= 1.5), modelr (>= 0.1.5), pillar (>=
1.4.2), purrr (>= 0.3.3), readr (>= 1.3.1), readxl
              (>= 1.3.1), reprex (>= 0.3.0), rlang (>= 0.4.1),
rstudioapi (>= 0.10), rvest (>= 0.3.5), stringr (>=
              1.4.0), tibble (>= 2.1.3), tidyr (>= 1.0.0), xml2 (>= 1.2.2)

> ttclasses <- read_csv("~/tmp/ttclasses.csv")
We do not have your data.
>
> #Filter data
>
> ttclasses <-ttclasses %>%
>
>     filter(str_detect(assessment, "Assignment"))
>
>   ttclasses <-ttclasses %>%  filter(str_detect(name, "Name"))
Without a result that summarizes the changes in the data composition at
each step, we cannot make any guesses as to your problem

> ##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")
Yes, do see ?strptime. That format assumes dates are in MM/DD/YY format,
i.e slashes as separators and 2 digit years. Getting the date format
wrong is a common way to create NA values. It is better not to overlay
such efforts on top of the original column name. That way you can still
make changes without redoing the entire data steps.
>
> ttclasses$name <- factor(ttclasses$name)
>
> Thanks & Regards
> Biplab Nayak



>
> On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall <[hidden email]> wrote:
>
>> Biplab,
>>
>> i'm not sure how to help you here, but this list pretty much runs on
>> plain ASCII (or, these days, utf-8) e-mail.  for the most part, without
>> attachments.  so, simply-formatted text, including code, with some
>> mechanism in the code to initialize any data structures (data frames,
>> matrices, etc.) needed for the example.
>>
>> some of this is described in the posting guide
>> ----
>> https://www.r-project.org/posting-guide.html
>> ----
>>
>> formatting your e-mail in this way will likely increase your odds of a
>> helpful reply.
>>
>> cheers, Greg
>>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.