This commit is contained in:
Martin Chan 2021-12-13 17:25:02 +00:00
Родитель a8848cef59
Коммит 291251c4fc
3 изменённых файлов: 59 добавлений и 25 удалений

Просмотреть файл

@ -1,13 +1,15 @@
#' @title Create Employee Experience Index from Person Query grouped by Day #' @title Create Employee Experience Index from Person Query grouped by Day
#' #'
#' @param data Data frame containing a Standard 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 #' @details
#' Function still under development. #' Function still under development.
#' Some `data.table` syntax is used to speed up performance when running daily #' Some `data.table` syntax is used to speed up performance when running daily
#' data. #' data.
#' #'
create_expi <- function(data, hrvar, return = "standard"){ create_expi <- function(data, hrvar, mingroup, return = "standard"){
# HR lookup --------------------------------------------------------------- # HR lookup ---------------------------------------------------------------
@ -15,6 +17,16 @@ create_expi <- function(data, hrvar, return = "standard"){
hr_df <- data %>% select(PersonId, !!sym(hrvar)) 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 ----------------------------------------------------------- # Daily metrics -----------------------------------------------------------
# Get `QuietDays` and `DeepWorkDay` based on Daily Data # Get `QuietDays` and `DeepWorkDay` based on Daily Data
@ -252,6 +264,7 @@ create_expi <- function(data, hrvar, return = "standard"){
hr_df, hr_df,
by = "PersonId" by = "PersonId"
) %>% ) %>%
filter(!!sym(hrvar) %in% pass_str) %>%
group_by(!!sym(hrvar)) %>% group_by(!!sym(hrvar)) %>%
summarise( summarise(
across( across(
@ -268,6 +281,7 @@ create_expi <- function(data, hrvar, return = "standard"){
hr_df, hr_df,
by = "PersonId" by = "PersonId"
) %>% ) %>%
filter(!!sym(hrvar) %in% pass_str) %>%
group_by(!!sym(hrvar)) %>% group_by(!!sym(hrvar)) %>%
summarise( summarise(
across( across(

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -62,6 +62,7 @@ library(flexdashboard)
expi_df <- params$data # Employee Experience Custom Query expi_df <- params$data # Employee Experience Custom Query
hrvar_str <- params$hrvar hrvar_str <- params$hrvar
mingroup <- params$mingroup
source("create_expi.R") source("create_expi.R")
source("vis_exp.R") source("vis_exp.R")
@ -72,7 +73,10 @@ expi_list <-
Meeting_hours_for_2_attendees = "Meeting_hours_1_on_1" Meeting_hours_for_2_attendees = "Meeting_hours_1_on_1"
) %>% ) %>%
totals_bind(target_col = hrvar_str) %>% # Add Total 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 expi_out <- expi_list[["standard"]] # component
@ -501,6 +505,14 @@ short_tb %>%
create_dt(rounding = 2) create_dt(rounding = 2)
``` ```
### Table - 3
```{r echo=FALSE}
expi_df %>%
hrvar_count(hrvar = hrvar_str, return = "table") %>%
create_dt(rounding = 0)
```
### Notes ### Notes
```{r} ```{r}