feat: implement mingroup size
This commit is contained in:
Родитель
a8848cef59
Коммит
291251c4fc
|
@ -1,13 +1,15 @@
|
|||
#' @title Create Employee Experience Index from Person Query grouped by Day
|
||||
#'
|
||||
#' @param data Data frame containing a Standard Person Query grouped by Day.
|
||||
#' @param hrvar String containing the grouping HR variable.
|
||||
#' @param mingroup Numeric variable specifying the minimum group size.
|
||||
#'
|
||||
#' @details
|
||||
#' Function still under development.
|
||||
#' Some `data.table` syntax is used to speed up performance when running daily
|
||||
#' data.
|
||||
#'
|
||||
create_expi <- function(data, hrvar, return = "standard"){
|
||||
create_expi <- function(data, hrvar, mingroup, return = "standard"){
|
||||
|
||||
# HR lookup ---------------------------------------------------------------
|
||||
|
||||
|
@ -15,6 +17,16 @@ create_expi <- function(data, hrvar, return = "standard"){
|
|||
|
||||
hr_df <- data %>% select(PersonId, !!sym(hrvar))
|
||||
|
||||
# Pass string ------------------------------------------------------------
|
||||
# Find groups which exceed the minimum group size
|
||||
|
||||
pass_str <-
|
||||
data %>%
|
||||
group_by(!!sym(hrvar)) %>%
|
||||
summarise(n = n_distinct(PersonId)) %>%
|
||||
filter(n >= mingroup) %>%
|
||||
pull(!!sym(hrvar))
|
||||
|
||||
# Daily metrics -----------------------------------------------------------
|
||||
|
||||
# Get `QuietDays` and `DeepWorkDay` based on Daily Data
|
||||
|
@ -252,6 +264,7 @@ create_expi <- function(data, hrvar, return = "standard"){
|
|||
hr_df,
|
||||
by = "PersonId"
|
||||
) %>%
|
||||
filter(!!sym(hrvar) %in% pass_str) %>%
|
||||
group_by(!!sym(hrvar)) %>%
|
||||
summarise(
|
||||
across(
|
||||
|
@ -268,6 +281,7 @@ create_expi <- function(data, hrvar, return = "standard"){
|
|||
hr_df,
|
||||
by = "PersonId"
|
||||
) %>%
|
||||
filter(!!sym(hrvar) %in% pass_str) %>%
|
||||
group_by(!!sym(hrvar)) %>%
|
||||
summarise(
|
||||
across(
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -62,6 +62,7 @@ library(flexdashboard)
|
|||
|
||||
expi_df <- params$data # Employee Experience Custom Query
|
||||
hrvar_str <- params$hrvar
|
||||
mingroup <- params$mingroup
|
||||
|
||||
source("create_expi.R")
|
||||
source("vis_exp.R")
|
||||
|
@ -72,7 +73,10 @@ expi_list <-
|
|||
Meeting_hours_for_2_attendees = "Meeting_hours_1_on_1"
|
||||
) %>%
|
||||
totals_bind(target_col = hrvar_str) %>% # Add Total
|
||||
create_expi(hrvar = hrvar_str, return = "list")
|
||||
create_expi(
|
||||
hrvar = hrvar_str,
|
||||
mingroup = mingroup,
|
||||
return = "list")
|
||||
|
||||
expi_out <- expi_list[["standard"]] # component
|
||||
|
||||
|
@ -501,6 +505,14 @@ short_tb %>%
|
|||
create_dt(rounding = 2)
|
||||
```
|
||||
|
||||
### Table - 3
|
||||
|
||||
```{r echo=FALSE}
|
||||
expi_df %>%
|
||||
hrvar_count(hrvar = hrvar_str, return = "table") %>%
|
||||
create_dt(rounding = 0)
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
```{r}
|
||||
|
|
Загрузка…
Ссылка в новой задаче