Data
#
dta <- read.csv("data0419.csv", header = T)
options(digits = 3)
pacman::p_load(tidyverse, ggplot2, knitr, furniture, reshape2)
dta <- dta %>% mutate( Gender = relevel(Gender, ref = "女"),
Sector = relevel(Sector, ref = "私立"),
Field1 = relevel(Field1, ref = "遊憩與運動學群"),
EduLv = factor(EduLv, levels=c("博士","碩士","普通大學","科技大學",
"技術學院","五專","三專",
"二專","高中","高職","國中")),
EduLv = relevel(EduLv, ref = "技術學院"),
Region = factor(Region, levels =c("宜花東離島","北北基","桃竹苗",
"中彰投","雲嘉南","高屏澎")),
Age = as.numeric(Age),
J_year = as.numeric(J_year),
JobZone = as.numeric(JobZone),
EduZone = as.numeric(EduZone),
JobZone_D = as.numeric(EduZone-JobZone),
Salary = as.numeric(Salary),
SubEduOver = relevel(SubEduOver, ref="符合工作要求"),
Core = recode_factor(as.factor(JobCor), "1" = "無關聯",
"2" = "部分關聯",
"3" = "核心關聯"),
SubEduOver = factor(SubEduOver,levels =c("符合工作要求","高於工作要求","低於工作要求")))%>%
filter(Age <= 65 & Age >= 20)
# data construction
glimpse(dta)
## Observations: 1,567
## Variables: 25
## $ SID <fctr> A10, A100, A103, A104, A105, A106, A107, A108, A1...
## $ Gender <fctr> 女, 女, 男, 女, 女, 女, 女, 女, 女, 男, 男, 男, 女, 男, 男, 女, 女...
## $ Sector <fctr> 國立(公立), 私立, 國立(公立), 國立(公立), 國立(公立), 私立, 私立, 國立(公立...
## $ EduLv <fctr> 碩士, 普通大學, 高職, 普通大學, 普通大學, 普通大學, 普通大學, 普通大學, 碩士, 碩...
## $ SubEduOver <fctr> 高於工作要求, 符合工作要求, 符合工作要求, 符合工作要求, 符合工作要求, 符合工作要求, 符...
## $ Require <fctr> 高中/高職, 普通大學, 高中/高職, 普通大學, 普通大學, 普通大學, 普通大學, 普通大學,...
## $ Field1 <fctr> 資訊學群, 外語學群, 工程學群, 文史哲學群, 文史哲學群, 大眾傳播學群, 大眾傳播學群, 藝...
## $ City <fctr> 高雄市, 苗栗縣, 高雄市, 南投縣, 嘉義市, 臺北市, 臺北市, 南投縣, 高雄市, 臺中市,...
## $ Category <fctr> 受雇於公營機關, 受雇於公營機關, 受雇者於私營企業, 受雇於公營機關, 受雇者於私營企業, 受雇...
## $ Staff <fctr> 50-99人, 50-99人, 2-9人, 100-199人, 10-29人, 30-49人, 3...
## $ Hours <int> 40, 70, 57, 51, 64, 50, 50, 47, 50, 60, 45, 40, 56...
## $ J_year <dbl> 8, 4, 21, 1, 6, 0, 1, 1, 17, 7, 3, 23, 1, 2, 1, 1,...
## $ J_total <dbl> 8, 4, 30, 1, 6, 0, 2, 2, 28, 7, 30, 26, 1, 10, 1, ...
## $ income <fctr> 2-3萬以下, 3-4萬以下, 3-4萬以下, 4-5萬以下, 2萬以下, 3-4萬以下, 3-4...
## $ SubMismatch <int> 2, 3, 5, 4, 5, 4, 3, 3, 4, 4, 4, 4, 5, 5, 3, 2, 4,...
## $ JobSat <int> 4, 3, 5, 6, 7, 5, 3, 6, 3, 5, 4, 7, 3, 4, 4, 4, 5,...
## $ EduZone <dbl> 5, 4, 2, 4, 4, 4, 4, 4, 5, 5, 3, 5, 4, 4, 4, 4, 5,...
## $ Region <fctr> 高屏澎, 桃竹苗, 高屏澎, 中彰投, 雲嘉南, 北北基, 北北基, 中彰投, 高屏澎, 中彰投,...
## $ Salary <dbl> 25000, 35000, 35000, 45000, 20000, 35000, 35000, 4...
## $ Age <dbl> 34, 30, 62, 25, 21, 24, 25, 26, 57, 35, 54, 54, 23...
## $ JobZone <dbl> 3, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 3, 2, 4,...
## $ JobCor <int> 1, 2, 1, 2, 1, 3, 1, 1, 1, 3, 1, 1, 3, 1, 3, 1, 2,...
## $ Core <fctr> 無關聯, 部分關聯, 無關聯, 部分關聯, 無關聯, 核心關聯, 無關聯, 無關聯, 無關聯, 核...
## $ ObjOver <fctr> over, adequate, under, adequate, adequate, adequa...
## $ JobZone_D <dbl> 2, 0, -1, 0, 0, 0, 0, 0, 1, 1, -1, 0, 0, 0, 1, 2, ...
# check and pick out
lapply(dta[,c("Sector", "Field1", "City", "Region","EduLv", "SubEduOver", "ObjOver")], levels)
## $Sector
## [1] "私立" "國外學校" "國立(公立)"
##
## $Field1
## [1] "遊憩與運動學群" "大眾傳播學群" "工程學群" "文史哲學群"
## [5] "外語學群" "生命科學學群" "生物資源學群" "地球與環境學群"
## [9] "法政學群" "社會與心理學群" "建築與設計學群" "財經學群"
## [13] "教育學群" "資訊學群" "管理學群" "數理化學群"
## [17] "醫藥衛生學群" "藝術學群"
##
## $City
## [1] "宜蘭縣" "花蓮縣" "金門縣" "南投縣" "屏東縣" "苗栗縣" "桃園市"
## [8] "高雄市" "基隆市" "雲林縣" "新北市" "新竹市" "新竹縣" "嘉義市"
## [15] "嘉義縣" "彰化縣" "臺中市" "臺北市" "臺東縣" "臺南市" "澎湖縣"
##
## $Region
## [1] "宜花東離島" "北北基" "桃竹苗" "中彰投" "雲嘉南"
## [6] "高屏澎"
##
## $EduLv
## [1] "技術學院" "博士" "碩士" "普通大學" "科技大學" "五專"
## [7] "三專" "二專" "高中" "高職" "國中"
##
## $SubEduOver
## [1] "符合工作要求" "高於工作要求" "低於工作要求"
##
## $ObjOver
## [1] "adequate" "over" "under"
# hunt for missing values by variables
apply(apply(dta, 1, is.na), 1, sum)
## SID Gender Sector EduLv SubEduOver Require
## 0 0 0 0 0 0
## Field1 City Category Staff Hours J_year
## 0 0 0 0 0 0
## J_total income SubMismatch JobSat EduZone Region
## 0 0 0 0 0 0
## Salary Age JobZone JobCor Core ObjOver
## 0 0 0 0 0 0
## JobZone_D
## 0
# pick out
names(dta)
## [1] "SID" "Gender" "Sector" "EduLv" "SubEduOver"
## [6] "Require" "Field1" "City" "Category" "Staff"
## [11] "Hours" "J_year" "J_total" "income" "SubMismatch"
## [16] "JobSat" "EduZone" "Region" "Salary" "Age"
## [21] "JobZone" "JobCor" "Core" "ObjOver" "JobZone_D"
p <- dplyr::select(dta, -City, -income, -JobSat)