HR Analytics: Exploring Employee Data in R
Ben Teusch
HR Analytics Consultant
Why focus on safety?
accident_data
year employee_id accident_time
1 2017 1 Morning
2 2016 4 Afternoon
hr_data
year employee_id location
1 2016 1 Northwood
2 2017 1 Northwood
joined_data <- left_join(hr_data, safety_data, by = c("year", "employee_id"))
joined_data
year employee_id location accident_time
1 2016 1 Northwood <NA>
2 2017 1 Northwood Morning
joined_data
year employee_id location accident_time
1 2016 1 Northwood <NA>
2 2017 1 Northwood Morning
joined_data %>% filter(accident_time == NA) # no results
joined_data %>% filter(is.na(accident_time)) # use is.na() instead
year employee_id location accident_type
1 2016 1 Northwood <NA>
5 == 5
TRUE
NA == NA
NA
is.na(NA)
TRUE
HR Analytics: Exploring Employee Data in R