HR 分析:用 R 探索员工数据
Ben Teusch
HR Analytics Consultant
为何重视安全?
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) # 无结果joined_data %>% filter(is.na(accident_time)) # 请改用 is.na()
year employee_id location accident_type
1 2016 1 Northwood <NA>
5 == 5
TRUE
NA == NA
NA
is.na(NA)
TRUE
HR 分析:用 R 探索员工数据