Merge pull request #3 from microsoft/feat/right-to-disconnect
Feature: Right to Disconnect Report
This commit is contained in:
Коммит
877f64de5c
|
@ -55,8 +55,17 @@ generate_report2(
|
|||
mingroup = 5
|
||||
)
|
||||
```
|
||||
The arguments that you should pass to each report will differ depending on the report template. Please read the corresponding `README` file in each report template subdirectory for the appropriate example.
|
||||
|
||||
For a full example on how to run the `minimal.Rmd` example in this directory, see `example-usage.R` located at the root of this repository.
|
||||
|
||||
### Report Templates
|
||||
|
||||
The current report templates are available:
|
||||
- [Minimal report](https://github.com/microsoft/VivaRMDReportMarketplace/tree/main/templates/minimal-example) - as a minimal example of the report that can be produced with the above workflow.
|
||||
- [Employee Experience Report](https://github.com/microsoft/VivaRMDReportMarketplace/tree/main/templates/exp-report) - a report on the Employee Experience Index.
|
||||
- [Right to Disconnect Report](https://github.com/microsoft/VivaRMDReportMarketplace/tree/main/templates/rtd-report) - a report on collaboration metrics related to the Right to Disconnect, including an analysis on weekends.
|
||||
|
||||
|
||||
## References
|
||||
- https://rstudio.github.io/rstudio-extensions/rmarkdown_templates.html
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
The following parameters describe the arguments that will be passed to within the report function.
|
||||
|
||||
- `data`: the input must be a data frame with the columns as a Standard Person Query, which is built using the `sq_data` inbuilt into the 'wpa' package.
|
||||
- `report_title`: string containing the title of the report, which will be passed to `set_title` within the RMarkdown template.
|
||||
- `hrvar`: string specifying the HR attribute that will be passed into the single plot.
|
||||
- `hrvar`: string specifying the HR attribute that will be passed into the single plot.
|
||||
- `mingroup`: numeric value specifying the minimum group size to filter the data by.
|
||||
|
||||
## Report Type
|
||||
|
||||
This is a **flexdashboard** RMarkdown report.
|
||||
|
||||
The standard YAML header would be as follows:
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
---
|
||||
params:
|
||||
data: data
|
||||
set_title: report_title
|
||||
hrvar: hrvar
|
||||
mingroup: mingroup
|
||||
title: "Org Insights | Employee Experience Report"
|
||||
# output:
|
||||
# flexdashboard::flex_dashboard:
|
||||
# orientation: rows
|
||||
# vertical_layout: fill
|
||||
---
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
# Right to Disconnect Report Template
|
||||
|
||||
## Parameters
|
||||
|
||||
The following parameters describe the arguments that will be passed to within the report function.
|
||||
|
||||
- `data`: the input must be a data frame with the columns as a Standard Person Query, which is built using the `sq_data` inbuilt into the 'wpa' package.
|
||||
- `report_title`: string containing the title of the report, which will be passed to `set_title` within the RMarkdown template.
|
||||
- `hrvar`: string specifying the HR attribute that will be passed into the single plot.
|
||||
- `mingroup`: numeric value specifying the minimum group size to filter the data by.
|
||||
- `min_activity`: numeric value specifying the minimum number of emails or instant messages sent for any given day to be included in the data. You may wish to use this argument to exclude low/non-activity days such as annual leave or public holidays.
|
||||
|
||||
## Report Type
|
||||
|
||||
This is a **flexdashboard** RMarkdown report.
|
||||
|
||||
The standard YAML header would be as follows:
|
||||
```
|
||||
output:
|
||||
flexdashboard::flex_dashboard:
|
||||
orientation: rows
|
||||
vertical_layout: fill
|
||||
```
|
||||
|
||||
## Report output
|
||||
|
||||
This report contains the following pages:
|
||||
- `Overview`
|
||||
- `Drill-down`
|
||||
- `Channels`
|
||||
- `Channels - %`
|
||||
- `Time Trend`
|
||||
|
||||
## Data preparation
|
||||
|
||||
No data preparation is required as long as it is a Standard Person Query grouped at the **daily** level. Daily grouping is essential for the report to display day of the week break down properly.
|
||||
|
||||
## Package pre-requisites
|
||||
|
||||
To run this report, you will need the following R packages installed:
|
||||
- `wpa`
|
||||
- `dplyr`
|
||||
- `lubridate`
|
||||
- `flexdashboard`
|
||||
|
||||
## Examples
|
||||
|
||||
For an example of the report output, see `rtd report.html`.
|
||||
|
||||
To run this report, you may run as an example:
|
||||
```R
|
||||
generate_report2(
|
||||
output_format = flexdashboard::flex_dashboard(
|
||||
orientation = "columns",
|
||||
vertical_layout = "fill"
|
||||
),
|
||||
output_file = "rtd report.html",
|
||||
output_dir = here::here("templates", "rtd-report"), # path for output
|
||||
rmd_dir = here::here("templates",
|
||||
"rtd-report",
|
||||
"rtd_report.Rmd"), # path to RMarkdown file,
|
||||
|
||||
# Custom arguments to pass to `minimal-example/minimal.Rmd`
|
||||
data = spq_df, # Variable containing daily person query data frame
|
||||
hrvar = "Organization",
|
||||
mingroup = 5,
|
||||
min_activity = 1,
|
||||
report_title = "Right to Disconnect Report"
|
||||
)
|
||||
```
|
|
@ -0,0 +1,115 @@
|
|||
Page 1
|
||||
=====================================
|
||||
|
||||
Column {data-width=150}
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
### Average day span
|
||||
|
||||
```{r}
|
||||
p_data %>%
|
||||
# filter(!(DayOfWeek %in% c("Saturday", "Sunday"))) %>%
|
||||
create_bar(
|
||||
metric = "Workweek_span", # Day span
|
||||
hrvar = NULL,
|
||||
return = "table"
|
||||
) %>%
|
||||
dplyr::pull(`Workweek_span`) %>%
|
||||
round(digits = 1) %>%
|
||||
flexdashboard::valueBox(
|
||||
value = .,
|
||||
caption = "Average day span"
|
||||
)
|
||||
```
|
||||
|
||||
### Average collaboration hours
|
||||
|
||||
```{r}
|
||||
p_data %>%
|
||||
create_bar(
|
||||
metric = "Collaboration_hours",
|
||||
hrvar = NULL,
|
||||
return = "table"
|
||||
) %>%
|
||||
dplyr::pull(`Collaboration_hours`) %>%
|
||||
round(digits = 1) %>%
|
||||
flexdashboard::valueBox(
|
||||
value = .,
|
||||
caption = "Average daily collaboration hours"
|
||||
)
|
||||
```
|
||||
|
||||
### Average after hours
|
||||
|
||||
```{r}
|
||||
p_data %>%
|
||||
create_bar(
|
||||
metric = "After_hours_collaboration_hours",
|
||||
hrvar = NULL,
|
||||
return = "table"
|
||||
) %>%
|
||||
dplyr::pull(`After_hours_collaboration_hours`) %>%
|
||||
round(digits = 1) %>%
|
||||
flexdashboard::valueBox(
|
||||
value = .,
|
||||
caption = "Average daily after hours"
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
### Some placeholder text
|
||||
|
||||
Weekend is assumed to be Saturday and Sunday.
|
||||
|
||||
Minimum activity is defined in the arguments, which is used to identify weekends.
|
||||
|
||||
Column {data-width=425}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Span per day
|
||||
|
||||
```{r}
|
||||
p_data %>%
|
||||
mutate(Workweek_span) %>%
|
||||
create_bar(
|
||||
metric = "Workweek_span",
|
||||
hrvar = hrvar_str
|
||||
)
|
||||
```
|
||||
|
||||
### Time to disconnect per day
|
||||
|
||||
```{r}
|
||||
p_data %>%
|
||||
mutate(Day_Span = Workweek_span) %>%
|
||||
mutate(`Disconnected hours per day` = 24 - Day_Span) %>%
|
||||
create_bar(
|
||||
metric = "Disconnected hours per day",
|
||||
hrvar = hrvar_str
|
||||
)
|
||||
```
|
||||
|
||||
Column {data-width=425}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Working hours per day
|
||||
|
||||
```{r}
|
||||
p_data %>%
|
||||
mutate(`Daily Collaboration Hours` = Collaboration_hours) %>%
|
||||
create_bar(
|
||||
metric = "Daily Collaboration Hours",
|
||||
hrvar = hrvar_str
|
||||
)
|
||||
```
|
||||
|
||||
### Working hours per day
|
||||
|
||||
```{r}
|
||||
p_data %>%
|
||||
mutate(`Daily Collaboration Hours` = Collaboration_hours) %>%
|
||||
create_bar(
|
||||
metric = "Daily Collaboration Hours",
|
||||
hrvar = hrvar_str
|
||||
)
|
||||
```
|
|
@ -0,0 +1,52 @@
|
|||
Channels
|
||||
=====================================
|
||||
|
||||
Column {data-width=50%}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Average email hours
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "Email_hours",
|
||||
title = "Average email hours",
|
||||
bar_fill = rgb2hex(r = 242, g = 200, b = 15)
|
||||
)
|
||||
```
|
||||
|
||||
### Average meeting hours
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "Meeting_hours",
|
||||
title = "Average meeting hours",
|
||||
bar_fill = rgb2hex(r = 253, g = 98, b = 94)
|
||||
)
|
||||
```
|
||||
|
||||
Column {data-width=50%}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Average call hours
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "Call_hours",
|
||||
title = "Average call hours",
|
||||
bar_fill = rgb2hex(r = 138, g = 212, b = 135)
|
||||
)
|
||||
```
|
||||
|
||||
### Average instant message hours
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "Instant_Message_hours",
|
||||
title = "Average IM hours",
|
||||
bar_fill = rgb2hex(r = 55, g = 70, b = 73)
|
||||
)
|
||||
```
|
|
@ -0,0 +1,56 @@
|
|||
Channels - %
|
||||
=====================================
|
||||
|
||||
Column {data-width=50%}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Average email hours
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "Email_hours",
|
||||
title = "Average email hours",
|
||||
bar_fill = rgb2hex(r = 242, g = 200, b = 15),
|
||||
return = "dist"
|
||||
)
|
||||
```
|
||||
|
||||
### Average meeting hours
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "Meeting_hours",
|
||||
title = "Average meeting hours",
|
||||
bar_fill = rgb2hex(r = 253, g = 98, b = 94),
|
||||
return = "dist"
|
||||
)
|
||||
```
|
||||
|
||||
Column {data-width=50%}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Average call hours
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "Call_hours",
|
||||
title = "Average call hours",
|
||||
bar_fill = rgb2hex(r = 138, g = 212, b = 135),
|
||||
return = "dist"
|
||||
)
|
||||
```
|
||||
|
||||
### Average instant message hours
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "Instant_Message_hours",
|
||||
title = "Average IM hours",
|
||||
bar_fill = rgb2hex(r = 55, g = 70, b = 73),
|
||||
return = "dist"
|
||||
)
|
||||
```
|
|
@ -0,0 +1,40 @@
|
|||
Time Trend
|
||||
=====================================
|
||||
|
||||
Column {data-width=100%} {.tabset}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Day Span over time
|
||||
|
||||
```{r}
|
||||
tt_viz(
|
||||
data = p_data,
|
||||
metric = "Workweek_span",
|
||||
threshold = 2,
|
||||
title = "Day Span"
|
||||
)
|
||||
```
|
||||
|
||||
### Collaboration Hours over time
|
||||
|
||||
```{r}
|
||||
tt_viz(
|
||||
data = p_data,
|
||||
metric = "Collaboration_hours",
|
||||
threshold = 1,
|
||||
title = "Collaboration hours"
|
||||
)
|
||||
```
|
||||
|
||||
### After Hours over time
|
||||
|
||||
```{r}
|
||||
tt_viz(
|
||||
data = p_data,
|
||||
metric = "After_hours_collaboration_hours",
|
||||
threshold = 0,
|
||||
title = "After hours"
|
||||
)
|
||||
```
|
||||
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
Overview
|
||||
=====================================
|
||||
|
||||
Column {data-width=33%}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Total employees
|
||||
|
||||
```{r}
|
||||
p_data %>%
|
||||
pull(PersonId) %>%
|
||||
n_distinct() %>%
|
||||
flexdashboard::valueBox(
|
||||
value = .,
|
||||
caption = "total employees",
|
||||
color = "info"
|
||||
)
|
||||
```
|
||||
|
||||
### Average working day span
|
||||
|
||||
```{r}
|
||||
avg_vb(
|
||||
data = p_data,
|
||||
metric = "Workweek_span",
|
||||
round = 1,
|
||||
caption = "Average working day span",
|
||||
fill = rgb2hex(r = 1, g = 92, b = 85)
|
||||
)
|
||||
```
|
||||
|
||||
### Working Day Span by Day of Week
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "Workweek_span",
|
||||
bar_fill = rgb2hex(r = 1, g = 92, b = 85),
|
||||
title = "Working Day Span"
|
||||
)
|
||||
```
|
||||
|
||||
Column {data-width=33%}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Start date
|
||||
|
||||
```{r}
|
||||
p_data %>%
|
||||
extract_date_range(return = "table") %>%
|
||||
dplyr::pull(Start) %>%
|
||||
# gsub(pattern = "Data from", replacement = "", x = .) %>%
|
||||
# gsub(pattern = "of", replacement = "", x = .) %>%
|
||||
flexdashboard::valueBox(
|
||||
value = .,
|
||||
caption = "",
|
||||
color = rgb2hex(r = 89, g = 89, b = 89)
|
||||
)
|
||||
```
|
||||
|
||||
### Average collaboration hours
|
||||
|
||||
```{r}
|
||||
avg_vb(
|
||||
data = p_data,
|
||||
metric = "Collaboration_hours",
|
||||
round = 1,
|
||||
caption = "Average daily collaboration hours",
|
||||
fill = rgb2hex(r = 1, g = 184, b = 170)
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
### Average daily collaboration hours
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "Collaboration_hours",
|
||||
bar_fill = rgb2hex(r = 1, g = 184, b = 170),
|
||||
title = "Daily collaboration hours"
|
||||
)
|
||||
```
|
||||
|
||||
Column {data-width=33%}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### End date
|
||||
|
||||
```{r}
|
||||
p_data %>%
|
||||
extract_date_range(return = "table") %>%
|
||||
dplyr::pull(End) %>%
|
||||
flexdashboard::valueBox(
|
||||
value = .,
|
||||
caption = "",
|
||||
color = rgb2hex(r = 89, g = 89, b = 89)
|
||||
)
|
||||
```
|
||||
|
||||
### Average after hours
|
||||
|
||||
```{r}
|
||||
avg_vb(
|
||||
data = p_data,
|
||||
metric = "After_hours_collaboration_hours",
|
||||
round = 1,
|
||||
caption = "Average daily after hours",
|
||||
fill = rgb2hex(r = 253, g = 98, b = 94)
|
||||
)
|
||||
```
|
||||
|
||||
### After hours per day
|
||||
|
||||
```{r}
|
||||
bar_dow(
|
||||
data = p_data,
|
||||
metric = "After_hours_collaboration_hours",
|
||||
bar_fill = rgb2hex(r = 253, g = 98, b = 94),
|
||||
title = "After hours collaboration"
|
||||
)
|
||||
```
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
Drill-down
|
||||
=====================================
|
||||
|
||||
Column {data-width=33%}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Average day span
|
||||
|
||||
```{r}
|
||||
|
||||
heatmap_dow(
|
||||
data = p_data,
|
||||
hrvar = hrvar_str,
|
||||
metric = "Workweek_span",
|
||||
title = "Day span",
|
||||
return = "topbox",
|
||||
grid_fill = rgb2hex(r = 1, g = 92, b = 85)
|
||||
)
|
||||
```
|
||||
|
||||
### Average day span
|
||||
|
||||
```{r}
|
||||
|
||||
heatmap_dow(
|
||||
data = p_data,
|
||||
hrvar = hrvar_str,
|
||||
metric = "Workweek_span",
|
||||
title = "Average working day span",
|
||||
grid_fill = rgb2hex(r = 1, g = 92, b = 85)
|
||||
)
|
||||
|
||||
```
|
||||
|
||||
### Average day span
|
||||
|
||||
```{r}
|
||||
|
||||
heatmap_dow(
|
||||
data = p_data,
|
||||
hrvar = hrvar_str,
|
||||
metric = "Workweek_span",
|
||||
title = "Day span",
|
||||
return = "table"
|
||||
) %>%
|
||||
knitr::kable()
|
||||
|
||||
```
|
||||
|
||||
Column {data-width=33%}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Average collaboration hours
|
||||
|
||||
```{r}
|
||||
heatmap_dow(
|
||||
data = p_data,
|
||||
hrvar = hrvar_str,
|
||||
metric = "Collaboration_hours",
|
||||
title = "Collaboration hours",
|
||||
return = "topbox",
|
||||
grid_fill = rgb2hex(r = 1, g = 184, b = 170)
|
||||
)
|
||||
```
|
||||
|
||||
### Average collaboration hours
|
||||
|
||||
```{r}
|
||||
heatmap_dow(
|
||||
data = p_data,
|
||||
hrvar = hrvar_str,
|
||||
metric = "Collaboration_hours",
|
||||
title = "Average collaboration hours",
|
||||
grid_fill = rgb2hex(r = 1, g = 184, b = 170)
|
||||
)
|
||||
```
|
||||
|
||||
### Average collaboration hours
|
||||
|
||||
```{r}
|
||||
heatmap_dow(
|
||||
data = p_data,
|
||||
hrvar = hrvar_str,
|
||||
metric = "Collaboration_hours",
|
||||
title = "Collaboration hours",
|
||||
return = "table"
|
||||
) %>%
|
||||
knitr::kable()
|
||||
```
|
||||
|
||||
Column {data-width=33%}
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
### Average day span
|
||||
|
||||
```{r}
|
||||
heatmap_dow(
|
||||
data = p_data,
|
||||
hrvar = hrvar_str,
|
||||
metric = "After_hours_collaboration_hours",
|
||||
title = "After hours",
|
||||
return = "topbox",
|
||||
grid_fill = rgb2hex(r = 253, g = 98, b = 94)
|
||||
)
|
||||
```
|
||||
|
||||
### Average day span
|
||||
|
||||
```{r}
|
||||
heatmap_dow(
|
||||
data = p_data,
|
||||
hrvar = hrvar_str,
|
||||
metric = "After_hours_collaboration_hours",
|
||||
title = "Average after hours",
|
||||
grid_fill = rgb2hex(r = 253, g = 98, b = 94)
|
||||
)
|
||||
```
|
||||
|
||||
### Average day span
|
||||
|
||||
```{r}
|
||||
heatmap_dow(
|
||||
data = p_data,
|
||||
hrvar = hrvar_str,
|
||||
metric = "After_hours_collaboration_hours",
|
||||
title = "After hours",
|
||||
return = "table"
|
||||
) %>%
|
||||
knitr::kable()
|
||||
```
|
||||
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,76 @@
|
|||
---
|
||||
params:
|
||||
data: data
|
||||
set_title: report_title
|
||||
hrvar: hrvar
|
||||
mingroup: mingroup
|
||||
min_activity: min_activity
|
||||
date: "`r Sys.Date()`"
|
||||
title: "`r params$set_title`"
|
||||
---
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
knitr::opts_chunk$set(
|
||||
echo = FALSE,
|
||||
# fig.height = 9,
|
||||
# fig.width = 16,
|
||||
message = FALSE,
|
||||
warning = FALSE
|
||||
)
|
||||
```
|
||||
|
||||
```{r include=FALSE}
|
||||
library(wpa)
|
||||
library(dplyr)
|
||||
library(lubridate)
|
||||
library(flexdashboard)
|
||||
|
||||
## parameter setting
|
||||
p_data <- params$data # Standard Person Query, grouped by day
|
||||
hrvar_str <- params$hrvar
|
||||
mingroup <- params$mingroup
|
||||
min_activity <- params$min_activity
|
||||
|
||||
p_data <-
|
||||
p_data %>%
|
||||
mutate(DayOfWeek = lubridate::wday(Date, label = TRUE, abbr = FALSE) %>%
|
||||
factor(levels =
|
||||
c(
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
"Sunday"
|
||||
)
|
||||
)) %>%
|
||||
filter(Emails_sent >= min_activity | Instant_messages_sent >= min_activity)
|
||||
|
||||
# Order by high to low
|
||||
hrvar_order <-
|
||||
p_data %>%
|
||||
workloads_sum(hrvar = "Site", return = "table", mingroup = 0) %>%
|
||||
arrange(desc(Workweek_span)) %>%
|
||||
dplyr::pull(group)
|
||||
|
||||
p_data[[hrvar_str]] <- factor(p_data[[hrvar_str]], levels = rev(hrvar_order))
|
||||
|
||||
source("auxiliary.R")
|
||||
|
||||
```
|
||||
|
||||
```{r child="pages/overview.Rmd"}
|
||||
```
|
||||
|
||||
```{r child="pages/page_2.Rmd"}
|
||||
```
|
||||
|
||||
```{r child="pages/channels.Rmd"}
|
||||
```
|
||||
|
||||
```{r child="pages/channels_2.Rmd"}
|
||||
```
|
||||
|
||||
```{r child="pages/drill_1.Rmd"}
|
||||
```
|
Загрузка…
Ссылка в новой задаче