[R] How to average minutes per hour per month in the form of '# hours #minutes'
PIKAL Petr
petr@p|k@| @end|ng |rom prechez@@cz
Mon Mar 22 08:44:51 CET 2021
Hallo
Sorry I cannot help you in tidyverse. I would use aggregate together with format
aggregate(whatever, list(format(datum, "%Y")), sum)
aggregate(whatever, list(format(datum, "%m")), sum)
Cheers
Petr
> -----Original Message-----
> From: R-help <r-help-bounces using r-project.org> On Behalf Of Dr Eberhard W
> Lisse
> Sent: Sunday, March 21, 2021 3:31 PM
> To: r-help using r-project.org
> Subject: [R] How to average minutes per hour per month in the form of '# hours
> #minutes'
>
> Hi,
>
> I have minutes worked by day (with some more information)
>
> which when using
>
> library(tidyverse)
> library(lubridate)
>
> run through
>
> CONSMINUTES %>%
> select(datum, dauer) %>%
> arrange(desc(datum))
>
> look somewhat like
>
> # A tibble: 142 x 2
> datum dauer
> <date> <int>
> 1 2021-03-18 30
> 2 2021-03-17 30
> 3 2021-03-16 30
> 4 2021-03-16 30
> 5 2021-03-16 30
> 6 2021-03-16 30
> 7 2021-03-11 30
> 8 2021-03-11 30
> 9 2021-03-11 30
> 10 2021-03-11 30
> # … with 132 more rows
>
> I can extract minutes per hour
>
> CONSMINUTES %>%
> select(datum, dauer) %>%
> group_by(week = format(datum, '%Y %V'))%>%
> summarise_if(is.numeric, sum)
>
> and minutes per month
>
> CONSMINUTES %>%
> select(datum, dauer) %>%
> group_by(month = format(datum, '%Y %m'))%>%
> summarise_if(is.numeric, sum)
>
> I need to show the time worked per week per month in the format of
>
> '# hours # minutes'
>
> and would like to also be able to show the average time per week per month.
>
> How can I do that (preferably with tidyverse :-)-O)?
>
> greetings, el
>
> ______________________________________________
> 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