Visualizing engagement data

HR Analytics: Exploring Employee Data in R

Ben Teusch

HR Analytics Consultant

Visualizing several variables at once

HR Analytics: Exploring Employee Data in R

The tidyr package

HR Analytics: Exploring Employee Data in R

Using tidyr::gather()

library(tidyr)

data %>%
    gather(columns, 
           key = "key", value = "value")
HR Analytics: Exploring Employee Data in R

Using tidyr::gather()

survey_summary             
# A tibble: 3 × 3
  department  average_engagement average_promotions
  <chr>                    <dbl>              <dbl>
1 Engineering               3.15              0.478
2 Finance                   3.24              0.540
3 Sales                     2.81              0.491
survey_summary %>% 
  gather(average_engagement,
         average_promotions,
         key = "key",
         value = "value")
# A tibble: 6 × 3
  department  key                value
  <chr>       <chr>              <dbl>
1 Engineering average_engagement 3.15 
2 Finance     average_engagement 3.24 
3 Sales       average_engagement 2.81 
4 Engineering average_promotions 0.478
5 Finance     average_promotions 0.540
6 Sales       average_promotions 0.491
1 tidyr::gather() has been replaced with tidyr::pivot_longer()
HR Analytics: Exploring Employee Data in R

Adding color to bar charts

survey_gathered <- survey_summary %>% 
  gather(average_engagement, average_promotions, 
         key = "key", value = "value")

ggplot(survey_gathered, aes(key, value, fill = department)) + geom_col()
HR Analytics: Exploring Employee Data in R

Adding color to bar charts

HR Analytics: Exploring Employee Data in R

Side-by-side bar charts

ggplot(survey_gathered, aes(key, value, fill = department)) +
  geom_col(position = "dodge")
HR Analytics: Exploring Employee Data in R

Side-by-side bar charts

HR Analytics: Exploring Employee Data in R

Adding facets

ggplot(survey_gathered, aes(x = key,
                            y = value,
                            fill = department)) +
  geom_col(position = "dodge") +
  facet_wrap(~ key, scales = "free")
HR Analytics: Exploring Employee Data in R

HR Analytics: Exploring Employee Data in R

Let's practice!

HR Analytics: Exploring Employee Data in R

Preparing Video For Download...