[R] Need help to fix the max date filter problem in the date input

David Winsemius dw|n@em|u@ @end|ng |rom comc@@t@net
Thu Jun 10 01:18:28 CEST 2021


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 <minshall using umich.edu> 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]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list