Rui Barradas
2023-Sep-30 11:02 UTC
[R] Grouping by Date and showing count of failures by date
?s 21:29 de 29/09/2023, Paul Bernal escreveu:> Dear friends, > > Hope you are doing great. I am attaching the dataset I am working with > because, when I tried to dput() it, I was not able to copy the entire > result from dput(), so I apologize in advance for that. > > I am interested in creating a column named Failure_Date_Period that has the > FAILDATE but formatted as YYYY_MM. Then I want to count the number of > failures (given by column WONUM) and just have a dataframe that has the > FAILDATE and the count of WONUM. > > I tried this: > pt <- PivotTable$new() > pt$addData(failuredf) > pt$addColumnDataGroups("FAILDATE") > pt <- PivotTable$new() > pt$addData(failuredf) > pt$addColumnDataGroups("FAILDATE") > pt$defineCalculation(calculationName = "FailCounts", > summariseExpression="n()") > pt$renderPivot() > > but I was not successful. Bottom line, I need to create a new dataframe > that has the number of failures by FAILDATE, but in YYYY-MM format. > > Any help and/or guidance will be greatly appreciated. > > Kind regards, > Paul > ______________________________________________ > R-help at 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.Hello, No data is attached. Maybe try dput(head(failuredf, 30)) ? And where can we find non-base PivotTable? Please start the scripts with calls to library() when using non-base functionality. Hope this helps, Rui Barradas -- Este e-mail foi analisado pelo software antiv?rus AVG para verificar a presen?a de v?rus. www.avg.com
John Kane
2023-Sep-30 11:11 UTC
[R] Grouping by Date and showing count of failures by date
To follow up on Rui Barradas's post, I do not think PivotTable is an R
command.
You may be thinking og the "pivot_longer" and "pivot_wider"
functions in
the {tidyr} package which is part of {tidyverse}.
On Sat, 30 Sept 2023 at 07:03, Rui Barradas <ruipbarradas at sapo.pt>
wrote:
> ?s 21:29 de 29/09/2023, Paul Bernal escreveu:
> > Dear friends,
> >
> > Hope you are doing great. I am attaching the dataset I am working with
> > because, when I tried to dput() it, I was not able to copy the entire
> > result from dput(), so I apologize in advance for that.
> >
> > I am interested in creating a column named Failure_Date_Period that
has
> the
> > FAILDATE but formatted as YYYY_MM. Then I want to count the number of
> > failures (given by column WONUM) and just have a dataframe that has
the
> > FAILDATE and the count of WONUM.
> >
> > I tried this:
> > pt <- PivotTable$new()
> > pt$addData(failuredf)
> > pt$addColumnDataGroups("FAILDATE")
> > pt <- PivotTable$new()
> > pt$addData(failuredf)
> > pt$addColumnDataGroups("FAILDATE")
> > pt$defineCalculation(calculationName = "FailCounts",
> > summariseExpression="n()")
> > pt$renderPivot()
> >
> > but I was not successful. Bottom line, I need to create a new
dataframe
> > that has the number of failures by FAILDATE, but in YYYY-MM format.
> >
> > Any help and/or guidance will be greatly appreciated.
> >
> > Kind regards,
> > Paul
> > ______________________________________________
> > R-help at 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.
> Hello,
>
> No data is attached. Maybe try
>
> dput(head(failuredf, 30))
>
> ?
>
> And where can we find non-base PivotTable? Please start the scripts with
> calls to library() when using non-base functionality.
>
> Hope this helps,
>
> Rui Barradas
>
>
> --
> Este e-mail foi analisado pelo software antiv?rus AVG para verificar a
> presen?a de v?rus.
> www.avg.com
>
> ______________________________________________
> R-help at 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.
>
--
John Kane
Kingston ON Canada
[[alternative HTML version deleted]]