【R语言】期末大作业

2023-10-31

头部:

---
title: "LZW HR_dashboard_report"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
---
<style>                     
.navbar {
  background-color:maroon;
  border-color:white;
}
.navbar-brand {
color:white!important;
}
</style> 

 数据预处理1:

knitr::opts_chunk$set(echo = FALSE, warning = FALSE)
rm(list=ls())
options(warn=-1)
library(readxl)
library(ggplot2)
library(recharts)
library(shiny)
library(flexdashboard)
library(ggalt)
library(DT)
library(maps)
library(mapdata)
library(sp)
library(dplyr)
library(ggthemes)
library(lubridate)
library(sqldf)
library(xts)
library(forecast)
library(quantmod)
library(zoo)
library(tidyr)
library(grid)

 
orders1 <- read_excel("G:/R default work directory/HR Dashboard_v1 - Americas.xlsx")
orders2 <- read_excel("G:/R default work directory/HR Dashboard_v1 - APAC.xlsx")
orders3 <- read_excel("G:/R default work directory/HR Dashboard_v1 - Europe.xlsx")
entry <- read_excel("G:/R default work directory/entry.xlsx")
exit <- read_excel("G:/R default work directory/exit.xlsx")
gross <- read_excel("G:/R default work directory/gross.xlsx")

orders1$Continent <- rep('North America',times=40)

a<-rep('Asia',times=30)
b<-rep('Oceania',times=15)
c<-rep('Asia',times=5)

orders2$Continent <- c(a,b,c)

orders3$Continent <-rep('Europe',times=50)

orders1$Area <- rep('Americas',times=40)

orders2$Area <- rep('APAC',times=50)

orders3$Area <- rep('Europe',times=50)

orders4<-merge(orders1, orders2, all=TRUE)
orders0<-merge(orders3, orders4, all=TRUE)
orders<-orders0[,-c(1,2,3,4,5,6,14,15,22)]
orders$`Date of Exit`<- as.Date(as.numeric(orders$`Date of Exit`),origin="1899-12-30")
rm(orders4)
ordersx <- orders[!orders$`Type of movement` == 'Exit',]
ordersl <- orders[!orders$`Type of movement` == 'Entry',]

FlashBoard部分:

# Overview{data-icon="fa-globe"}
Column {data-width=600}{.tabset}
-------

数据预处理2:

names(exit)=c('country','counts','lat','long')
names(entry)=c('country','counts','lat','long')
names(gross)=c('country','counts','lat','long')

exit$long=as.numeric(as.character(exit$long))
exit$lat=as.numeric(as.character(exit$lat))
exit$counts=as.numeric(as.character(exit$counts))
entry$long=as.numeric(as.character(entry$long))
entry$lat=as.numeric(as.character(entry$lat))
entry$counts=as.numeric(as.character(entry$counts))
gross$long=as.numeric(as.character(gross$long))
gross$lat=as.numeric(as.character(gross$lat))
gross$counts=as.numeric(as.character(gross$counts))

exit$country[1]<-"United States of America"
entry$country[1]<-"United States of America"

FlashBoard部分:

### 入职员工分布

地图1:

worldcounts<-entry

b<-echartr(worldcounts, country, counts, type="map_world", subtype="move + scale") %>% setDataRange(splitNumber=0, color=getColFromPal('macarons')) %>% setTitle("入职员工分布")

b

FlashBoard部分:

### 离职员工分布

地图2:

worldcounts<-exit

a<-echartr(worldcounts, country, counts, type="map_world", subtype="move + scale")  %>%  setDataRange(splitNumber=0, color=getColFromPal('macarons')) %>% setTitle("离职员工分布")
a

FlashBoard部分:

### 员工变动分布图

员工变动分布图:

#员工变动分布图

mp<-NULL #定义一个空的地图 

mapworld<-borders("world",colour = "gray50",fill="white") #绘制基本地图 

mp<-ggplot()+mapworld+ylim(-90,90) + geom_point(aes(x=gross$long, y=gross$lat,size=gross$counts), color="red", alpha=0.5) + scale_size(range=c(2,9))+xlab("Longitude")+ylab("Latitude") + labs(size = "The Number of Movement") + theme (legend.position = "top",legend.text = element_text( face= "bold" ,size=10)) 

mp #将地图呈现出来

FlashBoard部分:

Column{data-width=85}
----
### 入职总人数

ValueBox1:

valueBox(93,icon = "fa-user-plus",color = "crimson")

FlashBoard部分:

### 离职总人数

ValueBox2:

valueBox(47,icon = "fa-user-minus",color = "coral")

FlashBoard部分:

### 入职流动比

仪表盘1:

gauge(round((93/140),2), min = 0, max = 1, 
gaugeSectors(success = c(0.6, 1), warning = c(0.2, 0.6), danger = c(0, 0.2)))

FlashBoard部分:

### 离职流动比

仪表盘2:

gauge(round((7/47),2), min = 0, max = 1, 
gaugeSectors(success = c(0.6, 1), warning = c(0.2, 0.6), danger = c(0, 0.2)))

FlashBoard部分:

### 非自愿离职

 仪表盘3:

gauge(round((47/140),2), min = 0, max = 1, 
gaugeSectors(success = c(0.6, 1), warning = c(0.2, 0.6), danger = c(0, 0.2)))

FlashBoard部分:

Column {data-width=315}
-----------
### 公司整体人员流动情况

图: 

echartr(mytable,Type.of.movement,Freq,type = 'pie')%>%
setTheme('macarons', calculable=TRUE)%>%
setSeries(radius = '65%')%>%
setTitle("Percentage of Entry and Exit")

FlashBoard部分:

### 公司整体人员流动情况

图: 

echartr(mytable,Type.of.movement,Freq,type = 'pie')%>%
setTheme('macarons', calculable=TRUE)%>%
setSeries(radius = '65%')%>%
setTitle("Percentage of Entry and Exit")

后续:

Studio {data-navmenu="Different Vision"}
=====================================

Column{data-width = 500}
---------
### 不同工作室人员流动数量
```{r}
mytable1<-xtabs(~Studio+`Type of movement`,data = orders)
mytable1 <- as.data.frame(mytable1)


echartr(mytable1, Studio, Freq, Type.of.movement, type='column', subtype='stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry and Exit across Studio")
```


Column{data-width = 500}
---
### 不同工作室人员流动比例
```{r}

echartr(mytable1, Studio, Freq,  facet=Type.of.movement, type='rose',subtype='radius')%>%
     setTheme('macarons', calculable=TRUE)%>%
     setSeries(radius = '40%')%>%
     setLegend(show = FALSE)%>%
     setTitle("Percentage of Entry and Exit across Studio")

```

Country {data-navmenu="Different Vision"}
=====================================

Column{data-width = 500}
---------
### 不同国家人员流动数量
```{r}
mytable2<-xtabs(~Country+`Type of movement`,data = orders)
mytable2 <- as.data.frame(mytable2)
echartr(mytable2, Country, Freq, Type.of.movement, type='column',subtype = 'stack')%>%
     setTheme('macarons', calculable=TRUE)%>%
     setTitle("Frequency of Entry and Exit across Country",textStyle = list(fontSize = 15))%>%
     setXAxis(axisLabel = list(rotate = 45))
```


Column{data-width = 500}
---
### 不同国家人员流动比例
```{r}
echartr(mytable2, Country, Freq,  facet=Type.of.movement, type='rose',subtype='radius')%>%
setTheme('macarons', calculable=TRUE)%>%
setSeries(radius = '40%')%>%
setTitle("Percentage of Entry and Exit across Country",textStyle = list(fontSize = 20))
```

Manager {data-navmenu="Different Vision"}
=====================================

Column{data-width = 500}
---------
### 不同领导人名下人员流动数量
```{r}
mytable3<-xtabs(~`Manager Name`+`Type of movement`,data = orders)
mytable3 <- as.data.frame(mytable3)
echartr(mytable3, Manager.Name, Freq, Type.of.movement, type='column',subtype = 'stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry and Exit Across Manager",textStyle = list(fontSize = 10))%>%
     setXAxis(axisLabel = list(rotate = 45))
```

Column{data-width = 500}
---
### 不同领导人名下人员流动比例
```{r}
echartr(mytable3, Manager.Name, Freq,facet= Type.of.movement, type='pie')%>%
setTheme('macarons', calculable=TRUE)%>%
  setSeries(radius = '40%')%>%
setTitle("Percentage of Entry and Exit across Manager")
```

Employment Type {data-navmenu="Different Vision"}
=====================================

Column{data-width = 500}
---------
### 不同岗位性质人员流动数量
```{r}
mytable4<-xtabs(~`Employment type`+`Type of movement`,data = orders)
mytable4 <- as.data.frame(mytable4)
echartr(mytable4, Employment.type, Freq, Type.of.movement, type='column',subtype = 'stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry and Exit across Employment Type")
```

Column{data-width = 500}
---
### 不同岗位性质人员流动比例
```{r}
echartr(mytable4, Employment.type, Freq, facet=Type.of.movement, type='rose',subtype='radius')%>%
    setTheme('macarons', calculable=TRUE)%>%
    setTitle("Percentage of Entry and Exit across Employment Type")
```

Continent {data-navmenu="Different Vision"}
=====================================

Column{data-width = 500}
---------
### 不同大洲人员流动数量
```{r}
mytable7<-xtabs(~`Continent`+`Type of movement`,data = orders)
mytable7 <- as.data.frame(mytable7)
echartr(mytable7, Continent, Freq, Type.of.movement, type='column',subtype = 'stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry and Exit across Continent")
```

Column{data-width = 500}
---
### 不同大洲人员流动比例
```{r}
echartr(mytable7, Continent, Freq, facet=Type.of.movement, type='rose',subtype='radius')%>%
setTheme('macarons', calculable=TRUE)%>%
setSeries(radius = '40%')%>%
setTitle("Percentage of Entry and Exit across Continent")
```

Area {data-navmenu="Different Vision"}
=====================================

Column{data-width = 500}
---------
### 不同地区人员流动数量
```{r}
mytable8<-xtabs(~`Area`+`Type of movement`,data = orders)
mytable8 <- as.data.frame(mytable8)
echartr(mytable8, Area, Freq, Type.of.movement, type='column',subtype = 'stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry and Exit across Area")
```

Column{data-width = 500}
---
### 不同地区人员流动比例
```{r}
echartr(mytable8, Area, Freq, facet=Type.of.movement, type='rose',subtype='radius')%>%
setTheme('macarons', calculable=TRUE)%>%
setSeries(radius = '40%')%>%
setTitle("Percentage of Entry and Exit across Area")
```

Job Title {data-navmenu="Different Vision"}
=====================================

Column{data-width = 500}
---------
### 不同岗位名称人员流动数量
```{r}
mytable9<-xtabs(~`Job Title`+`Type of movement`,data = orders)
mytable9 <- as.data.frame(mytable9)
echartr(mytable9, Job.Title, Freq, Type.of.movement, type='column',subtype = 'stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry and Exit across Job")
```

Column{data-width = 500}
---
### 不同岗位名称人员流动比例
```{r}
echartr(mytable9, Job.Title, Freq, facet=Type.of.movement, type='rose',subtype='radius')%>%
setTheme('macarons', calculable=TRUE)%>%
setLegend(show = FALSE)%>%
setSeries(radius = '40%')%>%
setTitle("Percentage of Entry and Exit across Job")
```


Country {data-navmenu="Entry"}
=====================================

Column {data-width=500}
-------

### 不同国家入职人数
```{r warning=FALSE}
mytable10<-xtabs(~`Country`+`Type of movement`,data = ordersx)
mytable10 <- as.data.frame(mytable10)

echartr(mytable10, Country, Freq, type='column',subtype = 'stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry across Country")
```

Column {data-width=500}
-------
### 不同国家入职比例
```{r}
echartr(mytable10, Country, Freq, facet=Type.of.movement, type='rose',subtype='radius')%>%
    setTheme('macarons', calculable=TRUE)%>%
         setSeries(radius = '60%')%>%
    setTitle("Percentage of Entry across Country ")
```

Continent {data-navmenu="Entry"}
=====================================

Column {data-width=500}
-------

### 不同大洲入职人数
```{r warning=FALSE}
mytable11<-xtabs(~`Continent`+`Type of movement`,data = ordersx)
mytable11 <- as.data.frame(mytable11)

echartr(mytable11, Continent, Freq, type='column',subtype = 'stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry across Continent")
```

Column {data-width=500}
-------
### 不同大洲入职比例
```{r}
echartr(mytable11, Continent, Freq, facet=Type.of.movement, type='rose',subtype='radius')%>%
    setTheme('macarons', calculable=TRUE)%>%
         setSeries(radius = '60%')%>%
    setTitle("Percentage of Entry across Continent ")
```

Area {data-navmenu="Entry"}
=====================================

Column {data-width=500}
-------
### 不同地区入职人数
```{r warning=FALSE}
mytable12<-xtabs(~`Area`+`Type of movement`,data = ordersx)
mytable12 <- as.data.frame(mytable12)

echartr(mytable12, Area, Freq, type='column',subtype = 'stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry across Area")
```

Column {data-width=500}
-------
### 不同地区入职比例
```{r}
echartr(mytable12, Area, Freq, facet=Type.of.movement, type='rose',subtype='radius')%>%
    setTheme('macarons', calculable=TRUE)%>%
         setSeries(radius = '60%')%>%
    setTitle("Percentage of Entry across Area ")
```



# Exit
Column {data-width=500}{.tabset}
-------
### 不同离职原因人数
```{r}
mytable5<-xtabs(~`Reason for Leaving`+`Type of movement`,data = ordersl)
mytable5 <- as.data.frame(mytable5)
echartr(mytable5, Reason.for.Leaving, Freq, type='column',subtype = 'stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry and Exit Across Reason")

```

### 不同离职原因比例
```{r}
echartr(mytable5, Reason.for.Leaving, Freq, facet=Type.of.movement, type='rose',subtype='radius')%>%
    setTheme('macarons', calculable=TRUE)%>%
         setSeries(radius = '60%')%>%
    setTitle("Percentage of Entry and Exit across Reason for Leaving ")
```

Column {data-width=500}{.tabset}
-------
### 不同流失类型人数
```{r warning=FALSE}
mytable6<-xtabs(~`Attrition Type`+`Type of movement`,data = ordersl)
mytable6 <- as.data.frame(mytable6)

echartr(mytable6, Attrition.Type, Freq, type='column',subtype = 'stack')%>%
setTheme('macarons', calculable=TRUE)%>%
setTitle("Frequency of Entry and Exit Across Attrition Type")
```

### 不同流失类型比例
```{r}
echartr(mytable6, Attrition.Type, Freq, facet=Type.of.movement, type='rose',subtype='radius')%>%
    setTheme('macarons', calculable=TRUE)%>%
         setSeries(radius = '60%')%>%
    setTitle("Percentage of Entry and Exit across Attrition Type ")

```


Americas {data-navmenu="Forecast"}
=====================================

Column {data-width=600}
-------
### 员工留存率:Americas
```{r}

file <- read_excel("G:/R default work directory/Americas-1.xlsx")
#file <- read_excel("G:/R default work directory/Americas-1.xlsx")
names(file)=c('Date1','type1','Date2','reason','type2','Work')
Dates.entry <- cut(file$Date1, breaks = "month") 
file <- data.frame(file, Dates.entry)
Dates.exit <- cut(file$Date2, breaks = "month") 
file <- data.frame(file, Dates.exit)
file <-file[-c(1,2,3,4,5,6)]


file.1<-table(file$Dates.entry)
file.2<-table(file$Dates.exit)
file.1<-data.frame(file.1)
file.2<-data.frame(file.2)
names(file.1)=c('time','counts')
names(file.2)=c('time','counts')

file.1<-file.1[,-c(1)]
file.2<-file.2[,-c(1)]

xts.1 <- xts(file.1,seq(as.POSIXct("2011-03-01"),len=103,by="month"))
chart_Series(xts.1) 

fit<-auto.arima(xts.1)
forecast <- forecast(fit,h=30,level=c(70))
plot(forecast)

xts.2 <- xts(file.2,seq(as.POSIXct("2019-01-01"),len=8,by="month"))
chart_Series(xts.2) 

fit<-auto.arima(xts.2)
forecast <- forecast(fit,h=10,level=c(30))
plot(forecast)
```

Column {data-width=400}
-------
### 分析

    图1、图3为采用“quantmod”包对美洲(Americas数据集)员工的入职和离职情况进行的时间序列相关分析结果,图为公司(美洲)该类员工入职/离职人数随时间变化的情况(2011年3月-2019年9月);图2、图4为依据截至目前的所有人员变动数据(美洲)、利用“forecast”包中的时间序列研究工具“差分整合移动平均自回归模型”(ARIMA模型),对入职/离职员工人数在未来一段时间内的变化进行估计,得到的结果。
    从图1、图3可见,公司(美洲)近两年(2018年-2019年第三季度)的新员工招募情况最为理想,相比前几年迎来爆发式增长,据此推测公司的福利待遇在提升、招募计划在扩大。同时,离职高潮在2019年初迎来峰值,公司(美洲)在一月份有4人离职,二月份有3人离职。离职员工主要分为工龄4-7年的老员工,以及工作不满一年的新进员工。新进员工离职可能原因为公司管理制度欠佳、薪酬待遇不理想、工作压力大、新员工对工作环境不适应等,需要管理层对此类问题提高重视;老员工近期出现同比较大幅度离职说明公司的改革制度可能触及老员工利益、或者大量招募员工对老员工的生存提出了挑战。一家公司的老员工是这家公司的中流砥柱,是公司众多资源培养下的、具有较高工作能力、熟悉公司具体业务的公司重要战略组成部分,近年老员工的流失警醒管理层应反思公司制度对老员工的实际影响,平衡上下级、新老员工的切身利益,助力公司更快、更好的成长。
    图2、图4则依据现有数据,对未来一段时间的员工入职/离职情况进行了预测。模型ARIMA对入职情况的预测精度为0.7,深度1/30,预测结果显示,在现有条件不变的情况下,未来一段时间入职员工数量会有振幅逐渐减小的可控震荡,最终趋于稳定。模型ARIMA对入职情况的预测精度为0.3,深度1/10,预测结果显示,短期内离职员工数量将维持稳定,不会呈明显下降趋势。因此,公司要在环境允许的前提下,适当改变公司制度,修正不当的安排和举措,降低近年暴增的离职率,同时在保证入职员工质量的前提下将员工入职率控制在合理和可接受的范围内。


Total Frequency{data-navmenu="Forecast"}
=====================================

Column {data-width=600}
-------
### 全体员工入职/离职情况
```{r cars9}
file1 <- read_excel("G:/R default work directory/HR Dashboard_v1 - Americas.xlsx")
file2 <- read_excel("G:/R default work directory/HR Dashboard_v1 - APAC.xlsx")
file3 <- read_excel("G:/R default work directory/HR Dashboard_v1 - Europe.xlsx")

file1<-merge(file1,file2,all=TRUE)
file1<-merge(file1,file3,all=TRUE)

file1 <-file1[-c(1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,20)]

#file1$'Date of Exit' <- as.Date(as.numeric(file1$'Date of Exit'))

names(file1)=c('Date1','type','Date2','reason','type2','Work')

Dates.entry <- cut(file1$Date1, breaks = "month") 
file1 <- data.frame(file1, Dates.entry)

Dates.exit <- cut(file1$Date2, breaks = "month") 
file1 <- data.frame(file1, Dates.exit)

file1 <-file1[-c(1,2,3,4,5,6)]


file.1<-table(file1$Dates.entry)
file.2<-table(file1$Dates.exit)
file.1<-data.frame(file.1)
file.2<-data.frame(file.2)
names(file.1)=c('time','counts')
names(file.2)=c('time','counts')



file.1<-file.1[,-c(1)]
file.2<-file.2[,-c(1)]

xts.1 <- xts(file.1,seq(as.POSIXct("2011-03-01"),len=103,by="month"))
chart_Series(xts.1) 

fit<-auto.arima(xts.1)
forecast <- forecast(fit,h=30,level=c(70))
plot(forecast)

xts.2 <- xts(file.2,seq(as.POSIXct("2019-01-01"),len=8,by="month"))
chart_Series(xts.2) 

fit<-auto.arima(xts.2)
forecast <- forecast(fit,h=10,level=c(30))
plot(forecast)

```

Column {data-width=400}
-------
### 分析
    
    该部分与对公司(美洲)的研究方法类似,研究对象扩大至公司在美洲、亚太、欧洲三地分公司全体员工的入职/离职情况。
    图1、图3为采用“quantmod”包对全体(Americas、APAC、Europe数据集)员工的入职和离职情况进行的时间序列相关分析结果;图2、图4为利用“forecast”包中的时间序列研究工具ARIMA模型,对入职/离职员工人数在未来一段时间内的变化进行估计,得出的结论。
    与美洲分公司的结果类似,公司整体情况显示,在过去8年中,前6年内,员工招募计划稳定,而在近2年,员工入职率暴增,一方面,原因可能来自公司自身的扩大和对人才需求的提升;另一方面,也与员工招募门槛的降低、公司治理结构的松散有一定关系。同时,预测结果显示,在现有条件既定的情况下,员工入职率和离职率会在短期震荡后趋于相对稳定的水平,但是不排除未来公司在制度和管理体系内的改革会对入职率和离职率产生新的影响。总体来讲,员工招募情况呈现亚健康状态。以下两点值得管理层思考:
    - 人才招募不是一朝一夕之事,结合许多大公司的发展历程,经验告诉我们,在创业过程中,公司各类人、财、物的积累方面,要遵循循序渐进的过程,保持稳定和健康的阶梯式发展,短期内的大量扩张必然反应公司某方面的不足和考虑欠佳。<br/>
    - 离职率的提升背后必然反映着某些制度、举措表现出的对新、老员工不同群体的恶意,公司管理层应当积极反思相关问题,对内协调各方利益、打造舒适健康的工作环境,对外营造良好口碑,成为一家制度更健全、招募更公开、管理更透明的优秀企业代表。


Total Ratio{data-navmenu="Forecast"}
=====================================

Column {data-width=600}
-------
### 2011年3月-2019年9月全体员工留存率、流失率
```{r cars10}
sum1<-(sum(file.1)-sum(file.2))/sum(file.1) 
sum2<-sum(file.2)/sum(file.1)
sum3<-data.frame(Class=c('留存率','流失率'),Count=c(sum1,sum2))

options(warn=-1)
echartr(sum3, Class, Count, type='rose', subtype='radius') %>% setTitle('员工留存率&流失率分布图') %>% setSeries(radius = '50%') %>% setTheme('macarons', calculable=TRUE)

```

Column {data-width=400}
-------
### 分析

    结合数据图我们知道,公司全周期的员工流失量占公司总体员工数量的1/3,这个比例十分高,而且员工流失数量上的增长主要集中在2019年的8个月期间。一方面这是客观必然,结合同期招募量的上涨,有一定员工流失是可以接受的,但很难说这种“流水式”的在岗模式不会成为公司未来发展的一种新的、负面的趋势,因为能够看出公司自2018年中启动的大量招募措施是大量员工离职的直接推手,客观条件不变离职率将居高不下。员工是公司的命脉,人永远是第一位的,公司应当结合离职员工去向、离职原因、工作许可等情况对离职员工展开分析,从就此而映射公司制度设置和管理层面的不足,并予以修正。

Reason for Leaving{data-navmenu="Forecast"}
=====================================

Column {data-width=600}
-------
### 时间轴上核心离职原因变更情况
```{r}

file1 <- read_excel("G:/R default work directory/HR Dashboard_v1 - Americas.xlsx")
file2 <- read_excel("G:/R default work directory/HR Dashboard_v1 - APAC.xlsx")
file3 <- read_excel("G:/R default work directory/HR Dashboard_v1 - Europe.xlsx")

file1<-merge(file1,file2,all=TRUE)
file1<-merge(file1,file3,all=TRUE)

file1 <-file1[-c(1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,20)]
file1 <-file1[-c(1,2,5,6)]

names(file1)=c('Date','reason')

Dates.exit <- cut(file1$Date, breaks = "month") 
file1 <- data.frame(file1, Dates.exit)

file1 <-file1[-c(1,3)]


reason1<-length(which(file1$reason=='Better compensation'))
reason2<-length(which(file1$reason=='Better opportunity'))
reason3<-length(which(file1$reason=='Personal reasons'))
reason4<-length(which(file1$reason=='Project end'))
reason5<-length(which(file1$reason=='Disciplinary Action'))
reason6<-length(which(file1$reason=='Performance'))
total=reason1+reason2+reason3+reason4+reason5+reason6

reason1<-reason1/total
reason2<-reason2/total
reason3<-reason3/total
reason4<-reason4/total
reason5<-reason5/total
reason6<-reason6/total

Reason<-data.frame(reason=c('Better compensation','Better opportunity','Personal reasons','Project end','Disciplinary Action','Performance'),count=c(reason1,reason2,reason3,reason4,reason5,reason6))

#echartr(Reason, reason, count, type='rose', 
#        subtype='radius') %>%
#    setTitle('离职原因分布图') %>% setSeries(radius = '75%') %>% setTheme('helianthus', calculable=TRUE)

g <- echartr(Reason, reason, count,facet=reason,type='ring',subtype = 'info') %>% 
    setTheme('macarons') %>%
    setTitle('离职原因分布', pos=c('center','center', 'horizontal')) 

width = 800
height = 600
g %>% setLegend(pos=c('center','top','vertical'), itemGap=height/25) %>%
    relocLegend(x=width/1.7, y=height/8)
```

Column {data-width=400}
-------
### 分析
    
    此图为公司(Americas、APAC、Europe数据集)员工离职原因分布。总体来看,员工离职原因相对客观、比例十分合理。员工主要的离职原因为去待遇更好的公司就职,约占六成;部分员工因自身家庭、身体等特殊原因离职,约占两成;另有少部分员工因纪律、表现等问题离职,约占两成。
    该离职原因分布逻辑合理,但体现如下问题:
    - 公司在体制、待遇等方面尚存较大提升空间,有机会留住更加优秀的员工。
    - 因纪律、表现等问题离职的员工存在,但占比合理,体现了公司管理体制的筛选效率,该部分优秀制度应合理保留,并结合公司自身发展情况进行调整。
    - “Project end”部分离职占比约为6%,此部分员工应为公司招募的临时员工,或外包项目成员,是健康合理的员工流失类型,公司在合理考察的基础上可以一定比例吸收该类员工,作为公司的永久员工。


Work Authorisation{data-navmenu="Forecast"}
=====================================

Column {data-width=600}
-------
### 入职/离职工作许可类型判定
```{r cars77}
file1 <- read_excel("G:/R default work directory/HR Dashboard_v1 - Americas.xlsx")
file2 <- read_excel("G:/R default work directory/HR Dashboard_v1 - APAC.xlsx")
file3 <- read_excel("G:/R default work directory/HR Dashboard_v1 - Europe.xlsx")

file1<-merge(file1,file2,all=TRUE)
file1<-merge(file1,file3,all=TRUE)

file1 <-file1[-c(1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,20)]
file1 <-file1[-c(1,3,4,5)]
names(file1)=c('type','work')

shai <- file1[file1$type == 'Exit',]

A<-length(which(shai$work=='Citizen'))
B<-length(which(shai$work=='Permanent Resident'))
total=A+B
A<-A/total
B<-B/total

shai<-data.frame(type=c('Citizen','Permanent Resident'),count=c(A,B))

g <- echartr(shai, type, count,facet=type,type='ring',subtype = 'info') %>% 
    setTheme('macarons') %>%
    setTitle('工作许可情况', pos=c('center','center', 'horizontal')) 

width = 800
height = 600
g %>% setLegend(pos=c('center','top','vertical'), itemGap=height/25) %>%
    relocLegend(x=width/1.45, y=height/8)

```

Column {data-width=400}
-------
### 分析


    此图为离职员工工作许可情况分布。如图所示,公司离职员工主要为当地居民,其次是拥有当地永久签证的外国居民,没有领工作签证的外国籍员工离职。该统计结果反映出,主要的离职员工均为在本地有找工作能力和永久居住能力的员工,这也反映出居民类和永签类职工具有更大的不确定性,以及更加明显的离职倾向。公司应当善于把握此类动向,给予重要的居民类和永签类职工以待遇提升、并加以挽留,防止重要员工流向竞争对手,并对未来五年内可能发生的此类员工的离职做好准备。此外,公司应加大对领工作签证的外籍员工的培养和资源投入,把握这一员工群体的相对稳固性,并发挥他们的潜在价值。

工作时限{data-navmenu="Forecast"}
=====================================

Column {data-width=600}
-------
### 离岗员工在岗时间分布

```{r}
file1 <- read_excel("G:/R default work directory/HR Dashboard_v1 - Americas.xlsx")
file2 <- read_excel("G:/R default work directory/HR Dashboard_v1 - APAC.xlsx")
file3 <- read_excel("G:/R default work directory/HR Dashboard_v1 - Europe.xlsx")

file1<-merge(file1,file2,all=TRUE)
file1<-merge(file1,file3,all=TRUE)

file1 <-file1[-c(1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,20)]

#file1$'Date of Exit' <- as.Date(as.numeric(file1$'Date of Exit'))

names(file1)=c('Date1','type','Date2','reason','type2','Work')

Dates.entry <- cut(file1$Date1, breaks = "month") 
file1 <- data.frame(file1, Dates.entry)

Dates.exit <- cut(file1$Date2, breaks = "month") 
file1 <- data.frame(file1, Dates.exit)

file1 <-file1[-c(1,2,3,4,5,6)]


exit<-file1 %>% drop_na(Dates.exit)
exit<-data.frame(exit)

time<-c(as.Date(exit$Dates.exit)-as.Date(exit$Dates.entry))
time<-data.frame(time)
time<-data.frame(c(1:47),time)
names(time)=c('Class','Count')

time$Count=as.numeric(time$Count)
time$Class=as.character(time$Class)

#echartr(time, point ,long, type='auto')
#echartr(time,point,width=600) %>%
 #  setTitle('Iris: Histogram of Sepal.Width') %>%
  # setTooltip(formatter='none') %>% setSeries(1, barWidth=100/13)
echartr(time, Class, Count, type='column') %>%
    setTitle('离岗员工在岗时间分布')

```

Column{data-width=400}
-----
### 分析

    此图为截至2019年9月,公司(Americas、APAC、Europe数据集)总计47名离职员工的在岗期间工龄分布图。如图所示,离职员工在岗最长期限为3075天,逾7年,最短为90天,约三个月。绝大部分员工离职时累计在岗时间超过两年,约七成员工员工离职时在岗时间超过1000天,为老员工。
    结合公司总体入职/离职情况,不应将员工于2019年开始出现的密集离职潮仅仅归咎于2018年开始的大量招募所引起的“新人试错成本”,而应该着眼于数据,明确当下公司呈现的老员工离职新趋势,将着眼点聚焦于新老员工利益均衡,以及对骨干员工的挽留等补救措施上。
    此外,员工的双向流动率(入职率、离职率)出现较大幅度波动也说明公司进入快速发展阶段,公司更应在此阶段良好把握发展机遇,快速代谢,替换工作能力欠缺者、招募工作水平优良者,对公司人力资源进行全面换血,从而推动自身制度水平和业务能力不断发展。



# Data{data-icon="fa-list"}

```{r}
datatable(orders, extensions = 'Buttons', options = list(dom = 'Bfrtip',buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),pageLength = 25))

```

# About Us{data-icon="fa-users"}
Column {data-width=333}
-----------
### 冷忞杰

<center><img src="冷忞杰.jpeg" width="300" height="400"/></center><br/><br/>
<center>姓名:冷忞杰</center>
<center>学号:2017212158</center>
<center>分工:数据预处理/地图绘制/新问题、新趋势预测分析<br/></center>

Column {data-width=334}
-----------
### 赵晓杰
<center><img src="赵晓杰.jpeg" width="300" height="400"/></center><br/><br/>
<center>姓名:赵晓杰</center>
<center>学号:2017212043</center>
<center>分工:数据预处理/公司入职、离职员工分析/Flexdashboard整合<br/></center>


Column {data-width=333}
-----------
### 王云舒
<center><img src="王云舒.jpeg" width="300" height="500"/></center><br/><br/>
<center>姓名:王云舒</center>
<center>学号:2017212022</center>
<center>分工:数据预处理/公司入职、离职员工分析/Flexdashboard整合<br/></center>

 

 

 

 

 

 

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【R语言】期末大作业 的相关文章

  • 使用带有语法的域来优化集合重载运算符的实现

    使用带有语法的域来优化集合重载运算符的实现 C 是一种高效且灵活的编程语言 但是在处理集合操作时 常常需要提供多个重载运算符 这会导致代码量增长 维护困难等问题 为了解决这些问题 可以使用boost proto模块来实现使用一个带有语法的域
  • 最详细的下载安装PicGo图床配合Typora使用

    1 node js下载安装 1 2 检验安装成功 2 PicGo下载安装 3 配置Gitee 配合PicGo使用 3 1 获取PicGo的token 4 配置PicGo 4 1 下载插件 4 2 配置图床 Gitee 4 3 配置Typor
  • Umi创建react项目之配置额外的 postcss 插件。

    步骤1 安装插件 注意 安装6 x x版本的postcss pxtorem 会报错 object Object is not a PostCSS plugin npm i lib flexible D npm i postcss pxtor
  • h5游戏使用微信h5支付,刷新页面问题解决

    遇到的问题 h5游戏 或任何h5程序 使用微信h5支付后 自动刷了页面 导致用户体验极差 问题根本原因 h5端使用微信支付时 使用了以下代码 window localtion href https wx tenpay com cgi bin
  • MySQL 从一个表中查出数据并插入到另一个表处理方案(详细)

    PS 来源表 t source 目标表 t target 第一种 来源表和目标表字段完全一致 insert into t target select from t source 第二种 来源表和目标表字段部分一致 只想导入来源表部分字段到目
  • Unity基础 单点和多点触摸

    总结一下触摸事件 最简单的鼠标单点点击触摸 也可以在安卓和IOS上面实现触屏的操作 OnMouseDown 鼠标按下 点击的一瞬间触发 OnMouseDrag 鼠标持续按住拖动触发 OnMouseEnter 鼠标经过物体时触发 OnMous
  • [PyTroch系列-2]:Facebook PyTroch简介、生态环境、开发架构、软件架构

    作者主页 文火冰糖的硅基工坊 文火冰糖 王文兵 的博客 文火冰糖的硅基工坊 CSDN博客 本文网址 PyTroch系列 2 Facebook PyTroch简介 生态环境 开发架构 软件架构 文火冰糖 王文兵 的博客 CSDN博客 第1章
  • git远程仓库新建了分支,但是vscode分支管理里还没有这个分支怎么办

    git远程仓库新建了分支 但是vscode分支管理里还没有这个分支怎么办 git终端输入以下命令 成功后再次查看 就有了 git fetch origin 分支名
  • Jenkins基础篇--Docker容器部署

    容器部署Jenkins的优势 1 安全 容器之间的进程是相互隔离的 单独容器环境稳定 宿主机中环境变量的修改 不容易影响容器的运行结果 2 更轻松地部署和扩展 容器可方便迁移 一次交付 多次利用 容器可将打包好的jenkins环境迁移到其他
  • spark-sql提交参数详解整理

    1 spark任务提交 当SPARK SQL开发完成后需要将其提交到大数据平台上去跑 提交的时候需要对要使用的资源参数进行设置 目的 a 让任务在正确的环境下运行 b 根据任务自身情况 设置合理参数 提高运行效率 2 设置参数说明 2 1
  • python是从abc发展_Python 简介

    Python 简介 Python 是一门解释型语言 因为无需编译和链接 你可以在程序开发中节省宝贵的时间 Python 解释器可以交互的使用 这使得试验语言的特性 编写临时程序或在自底向上的程序开发中测试方法非常容易 Python 是面向对
  • 简单易懂矩阵螺旋打印

    简单易懂矩阵螺旋打印 C语言 给定一个 m 行 n 列的矩阵 请按照顺时针螺旋的顺序输出矩阵中所有的元素 输入格式 首先在第一行输入 2 个整数 分别对应题目描述中的 mm 和 nn 1 leq m n leq 1001 m n 100 之
  • 设置入校时间字段的有效性规则为_2012年计算机二级Access第二十六套上机试题及答案详解...

    1 基本操作题 在考生文件夹下 存在一个数据库文件 samp1 mdb 和一个图像文件 photo bmp 在数据库文件中已经建立一个表对象 tStud 试按以下操作要求 完成各种操作 1 设置 ID 字段为主键 并设置 ID 字段的相应属
  • UE4 C++ 用蓝图调用C++里定义的变量、方法

    UE4 C 用蓝图调用C 里定义的变量 方法 这是一个Object的C 脚本 h UCLASS Blueprintable 可被蓝图继续 class BASICTRAINING API UMyObject public UObject GE
  • 企业微信接入自研小程序流程

    一 背景 企业微信是企业内部办公常用的即时通讯工具 可以作为企业内部工作的枢纽 例如 重要内容通知 重要应用的集成等 二 自研程序接入企业微信配置 1 登录企业微信管理后台https work weixin qq com 2 找到应用管理
  • java -jar xxx.jar中没有主清单属性

    使用Spring Initailizr创建的项目 使用mvn打包后 java jar xxx jar显示xxx jar中没有主清单属性 去掉标签即可
  • Java实现阿里云短信发送功能(保姆级!!!搞懂短信功能,这一篇就够了!)

    目录 一 准备工作 1 功能如何切入 2 为什么要用阿里云来实现 二 阿里云部分 三 代码部分 OK 分享结束 收 一 准备工作 1 功能如何切入 第一步 分析业务需求 想要实现短信通知功能那就要有短信的收发双方 而手机上的短信功能需要占用
  • FFmpeg滤镜:制作图片视频流

    iPhone相册有个 为你推荐 功能 它会挑选一些照片形成一个主题 点击后可以像视频一样播放 那么 怎样才能把多张照片转成一个视频文件呢 使用FFmpeg可以这么来做 ffmpeg f image2 framerate 0 5 i D MT
  • Qt使用QSplitter实现分割窗口

    分割窗口在应用程序中经常用到 它可以灵活分布窗口布局 经常用于类似文件资源管理器的窗口设计中 然后抱着这样的想法简单的实现了下 cpp view plain copy print main cpp include
  • Android之通过BaseAdapter自定义适配器的使用

    通过BaseAdapter创建自定义适配器 在所有的适配器中 通过BaseAdapter定义的适配器非常好用 可以自定义ListView每行布局的样式 使用非常的广泛 是开发过程中必不可少的 下面看一个效果图 接下来一起来实现聊天列表 1

随机推荐

  • 在 ROS 中使用 Protobuf 替代 ros msg

    转自 https segmentfault com a 1190000012734275 Background 做 ROS 相关开发的 应该都知道 ros msg 有个非常大的槽点 ros msg 扩展性较差 即如果 msg 的字段发生变化
  • JAVA 输出一个会动的爱心

    以下是 Java 代码 可以在控制台输出一个会动的爱心 public class Love public static void main String args throws InterruptedException while true
  • 看完百度文心一言的魔性作图,我头都笑掉了...

    近日看到网友们用百度文心一言来作图 看了后我都愣住了 1 AI 作画 车水马龙 2 AI 作画 驴肉火烧 3 AI 作画 唐伯虎点秋香 4 AI 作画 鱼香肉丝 5 AI 作画 胸有成竹 6 AI 作画 夫妻肺片 7 AI 作画 红烧狮子头
  • 【GUI】Python图形界面(一)

    Python图形界面 一 第一个界面 1 了解模块代码的组成 导入库 PySimpleGUI 定义布局 确定行数 创建窗口 事件循环 关闭窗口 1 导入库 import PySimpleGUI as sg 2 定义布局 确定行数 layou
  • SharePreference原理

    SharedPreferences是Android提供的数据持久化的一种手段 适合单进程 小批量的数据存储与访问 因为SharedPreferences的实现是基于单个xml文件实现的 并且 所有持久化数据都是一次性加载到内存 如果数据过大
  • Error Handling with C++ Exceptions, Part 1

    by Chuck Allison Error Handling Alternatives With the traditional programming languages of yore a developer s alternativ
  • 电流电压曲线 vc源码_如何真正理解三极管伏安特性曲线在饱和区的含义

    初次学习三极管工作原理的时候 往往会对三极管的伏安特性曲线非常困惑 特别是饱和区的性质 本文就讨论这方面的内容 三极管的工作电路如图所示 图一 三极管工作电路 按照上述电路得出三极管的伏安特性如图所示 教科书中一般都这样描述三极管的三个工作
  • 快排算法实现

    找到分区点 把数组元素放到分区点两侧 再对分区点两侧数组进行排序 完成快排 同样递归实现快排 递归公式 递归终止条件 当所分区只有一个元素是 即元素下标相同时 递归终止 并返回 快排实现目的 对数组进行排序 实现过程 传递一个数组和数组起始
  • wangEditor富文本编辑器图片/视频上传

    wangEditor 有丰富的 API 和足够的扩展性 允许我们自定义开发菜单 模块 插件等 在Vue React中运用也很方便 因此本文介绍下vue中富文本上传图片和视频 安装引入后富文本有显示上传图片按钮 点击上传后会报没有配置上传地址
  • 14. TypeScript 自定义类型

    TypeScript 自定义类型 1 Diff实现 求两个对象不同的部分 let person1 name 123 age 11 address 456 let person2 address 123 type Diff
  • 基于Python+Pytest+Selenium的自动化测试之PO模式简介

    在实际的软件研发过程中 往往会存在项目时间紧张 待测工作量大 待测的功能点较多 但是团队测试人员有限 难以全部测试覆盖的问题 针对问题 我们可以通过自动化测试去解决一些测试工作中遇到的实际问题 把一些工作写成代码 交给机器去处理和执行 解放
  • java中常见的异常及处理方法

    1 java lang nullpointerexception 这个异常大家肯定都经常遇到 异常的解释是 程序遇上了空指针 简单地说就是调用了未经初始化的对象或者是不存在的对象 这个错误经常出现在创建图片 调用数组这些操作中 比如图片未经
  • Ajax基本案例详解之load的实现

    Ajax的load实现 看这篇之前建议大家去看看前面两篇文章 1 Ajax基本案例详解之 ajax的实现 2 Ajax基本案例详解之 get的实现 现在写一下 load 里面的主要内容 semail load doindex jsp ema
  • git恢复修改的文件

    文件修改后想反悔 三种情况 1 未进行任何操作 仅仅修改了文件 2 执行了git add将文件推到了暂存区 3 执行了git commit将文件推到了本地仓库 处理方法 针对情况1 只需要执行git checkout 文件名 情况2 首先g
  • linux常用命令汇总

    内存 cpu查看 free h 以合适内存单位显示内存情况 free s 数字 每几秒刷新内存显示 top 按e切换显示单位 防火墙 centos7 查看防火墙状态 firewall cmd state 停止firewall systemc
  • 服务器无法加载海康sdk依赖的问题

    首先遇到的jna jar和examples jar无法加载的问题 尝试了很多方法无效 以下方法实测有效 其次是动态链接库无法加载的问题 而且是播放库 我的方法比较简单 netsdk加载出来就行了 播放库用不到 删掉引用就行了 最后 我尝试了
  • Android程序员必备!Android学习笔记在互联网上火了,成功定级腾讯T3-2

    前言 2020年是转折的一年 上半年疫情原因 很多学android开发的小伙伴失业了 虽找到了一份工作 但高不成低不就 下半年金九银十有想法更换一份工作 很多需要大厂面试经验和大厂面试真题的小伙伴 想提前准备刷下题 接下来分享一份我的字节跳
  • 财务风险管理的内容

    财务风险管理的内容 一 筹资风险管理 筹资风险来源于两个方面 一是偿债风险 由于借入资金严格规定了借款方式 还款期限和还款金额 如果企业负债较多 而经营管理和现金管理不善 可能导致企业不能按期还本付息 就会产生偿债风险 偿债风险如不能通过财
  • nginx:accept() failed (24: Too many open files)解决方法

    有一台服务器访问量非常高 使用的是nginx 错误日志不停报以下错误 2010 05 26 08 53 49 alert 13576 0 accept failed 24 Too many open files 2010 05 26 08
  • 【R语言】期末大作业

    头部 title LZW HR dashboard report output flexdashboard flex dashboard orientation columns vertical layout fill source cod