员工季度考核评分表分析 in R

Author

Alex

Published

October 14, 2024

1. 读取考核数据

1.1 文件路径

Code
#{getwd()} 获取当前工作目录
library(readxl)
library(tidyverse)
library(knitr)
library(ggplot2)
library(ggthemes)
library(here)
library(showtext)
library(ggblanket)
set_blanket(
  mode = dark_mode_r(),
  font_family = "wqy-microhei",
  theme = light_mode_r() + mode_orientation_to_x()
)
library(plotly)
showtext_auto()
path <- getwd() #设置工作目录
file <- here(path, "scores.xlsx")
file
[1] "/Users/alex/Rlearning/score_test/score_test/scores.xlsx"

1.2 读取数据

Code
data <- read_excel(file,skip = 1) |> 
  select(-starts_with (c("主管领导",'备注'))) |>
  filter(!姓名 %in% c("张集锋","李瑞娟",'龙湘珍')) |> 
  rename(name=姓名,  
         score = 总分,  
         department= 部门,
         score_A1 =评分表A1, 
         score_B1 =评分表B1,
         score_A2 =评分表A2,
         score_B2 =评分表B2,
         plus = 加减分,
         leader= 部门负责人,
         vice_general = 分管领导,)

1.3 数据表格

1.3.1 概览

Code
anly_data <- data |> 
  select(-c(序号,职务)) |> 
  group_by(department) |> 
  mutate(mean_score=round(mean(score),2),.before = 3)  |> 
  arrange(department) 
  
anly_data
# A tibble: 44 × 11
# Groups:   department [3]
   name   department mean_score score_A1 score_A2 score_B1 score_B2 plus  leader
   <chr>  <chr>           <dbl>    <dbl>    <dbl>    <dbl>    <dbl> <lgl>  <dbl>
 1 方琦   BIM中心          93.6       92       92       88       88 NA      90  
 2 张凯   BIM中心          93.6       95       95       91       91 NA      93  
 3 刘志强 BIM中心          93.6       97       97       97       97 NA      97  
 4 段晓莉 BIM中心          93.6       95       95       96       96 NA      95.5
 5 马海珍 BIM中心          93.6       92       92       94       94 NA      93  
 6 胡亚丽 BIM中心          93.6       94       94       88       88 NA      91  
 7 宋彩娟 BIM中心          93.6       92       92       95       95 NA      93.5
 8 姜艳萍 BIM中心          93.6       95       95       89       89 NA      92  
 9 陈望   BIM中心          93.6       95       95       91       91 NA      93  
10 赵新光 BIM中心          93.6       97       97       96       96 NA      96.5
# ℹ 34 more rows
# ℹ 2 more variables: vice_general <dbl>, score <dbl>

1.3.2 部门汇总

Code
suminfo <- anly_data |> 
  group_by(department) |> 
  summarise(counts=n(),Leader_score=round(mean(leader),2),Vice_socre=round(mean(vice_general),2)) |> 
  rename(Department=department,
         Counts=counts)

kable(suminfo)
Department Counts Leader_score Vice_socre
BIM中心 20 93.55 93.55
创作一室 9 94.06 93.78
创作二室 15 92.10 91.77

2. 图形展示

2.1 数据分布

Code
p <- anly_data |> 
      ggplot(mapping = aes(x=score,fill=department,color=department))+
        geom_histogram(binwidth = 1)+
      facet_wrap(~department)

ggplotly(p)

2.2 部门数据violin

Code
P <- anly_data |>
  ggplot(aes(x = department, y = score, fill = department)) +
  geom_violin() +
  geom_jitter(width = 0.2) +
  theme_minimal()

ggplotly(P)

2.3 部门数据boxplot

Code
anly_data |> 
  ggplot(aes(x=department,y=score,fill=department,color=department)) +
    geom_boxplot() +
    geom_jitter(width = 0.2) +
    theme_minimal()

2.4 分管领导评分

Code
library(ggridges)
vice <- anly_data |>
  ggplot(aes(x = vice_general,y=department, fill = department, colour = department)) +
  geom_density_ridges(alpha = 0.5, show.legend = FALSE) +
  labs(title = "分管评分密度", x = "分管领导评分") +
  # facet_grid(department~.) +
  theme_minimal()

vice

2.5 部门领导评分

Code
library(ggridges)
leader <- anly_data |>
  ggplot(aes(x = leader, y=department, fill = department, colour = department)) +
  geom_density_ridges(alpha = 0.5, show.legend = FALSE) +
  labs(title = "部门评分密度", x = "部门负责人评分") +
  theme_minimal()

leader

3. 相关性分析

3.1 评分表A1与评分表A2的关系

Code
anly_data |>
  ggplot(aes(x = score_A1, y = score_A2, color = department,pch=department,lty=department)) +
  geom_jitter() +
  geom_smooth(method = "lm", se = FALSE) +
  labs(title = "评分表A1与评分表A2的关系", x = "评分表A1", y = "评分表A2") +
  theme_minimal()

3.2 评分表B1与评分表B2的关系

Code
anly_data |>
  ggplot(aes(x = score_B1, y = score_B2, color = department,pch=department,lty=department)) +
  geom_jitter() +
  geom_smooth(method = "lm", se = FALSE) +
  labs(title = "评分表B1与评分表B2的关系", x = "评分表B1", y = "评分表B2") +
  theme_minimal()

3.3 部门与分管评分关系

Code
anly_data |>
  ggplot(aes(x = leader, y = vice_general, color = department,pch=department,lty=department)) +
  geom_jitter() +
  geom_smooth(method = "lm", se = FALSE) +
  labs(title = "部门负责人 与 分管领导评分关系", x = "部门负责人", y = "分管领导") +
  theme_minimal()

3.4 部门与分管评分分布

Code
anly_data |>
  ggplot(aes(x = department, color = department)) +
  geom_point(aes(y = vice_general,shape = 'Vice'),color='orange',size=4,position = position_jitterdodge()) +
  geom_point(aes(y = leader,shape = "Leader"),color='lightblue',size=4,position = position_jitterdodge()) +
  theme_minimal() 

4. TOP3

4.1 TOP3 by Total Score

Code
top3 <- anly_data |>
  select(name,department,score) |>
  group_by(department) |>
  top_n(3, score) |>
  mutate(rank=row_number()) |>
  arrange(department, desc(score))

top3 |> 
  kable()
name department score rank
刘志强 BIM中心 97 1
刘俊超 BIM中心 97 2
杨曾光 BIM中心 97 3
胡龙 创作一室 98 2
朱宇 创作一室 97 3
张继源 创作一室 96 1
程笑雨 创作二室 96 1
王燕皓 创作二室 96 2
郑有池 创作二室 96 3

4.2 TOP3 by leader

Code
top3_leader <- anly_data |>
  select(name,department,leader) |>
  group_by(department) |>
  arrange(desc(leader)) |>
  top_n(3, leader) |>
  mutate(rank=row_number()) |>
  arrange(department, desc(leader))

top3_leader |>
  kable()
name department leader rank
刘志强 BIM中心 97 1
刘俊超 BIM中心 97 2
杨曾光 BIM中心 97 3
胡龙 创作一室 98 1
朱宇 创作一室 97 2
张继源 创作一室 96 3
程笑雨 创作二室 97 1
王燕皓 创作二室 96 2
郑有池 创作二室 96 3

4.3 TOP3 by vice

Code
top3_vice <- anly_data |>
  select(name,department,vice_general) |>
  group_by(department) |>
  arrange(desc(vice_general)) |>
  top_n(3, vice_general) |>
  mutate(rank=row_number()) |>
  arrange(department, desc(vice_general))
top3_vice |>
  kable()
name department vice_general rank
刘志强 BIM中心 97.0 1
刘俊超 BIM中心 97.0 2
杨曾光 BIM中心 97.0 3
胡龙 创作一室 98.0 1
朱宇 创作一室 97.0 2
张继源 创作一室 96.0 3
王燕皓 创作二室 96.0 1
郑有池 创作二室 96.0 2
孙祎璐 创作二室 95.5 3

5. 结论

  • 通过数据分析,可以看出各部门员工的评分分布情况,以及部门负责人和分管领导的评分情况。

  • 通过相关性分析,可以看出评分表A1与评分表A2的关系,评分表B1与评分表B2的关系,部门负责人与分管领导的评分关系。

  • 通过TOP3的分析,可以看出各部门的TOP3员工,以及部门负责人和分管领导的TOP3员工。

  • 通过数据分析,可以为公司的人事管理提供参考依据。

  • 本次分析结果仅供参考,具体情况具体分析。

  • 根据评分规律发现,不同的leader和vice对部门员工的评分标准尺度很难横向对比,需要进一步优化评分标准。