dta <- read.csv("data0417-3.csv", header = T)
options(digits = 3)
pacman::p_load(tidyverse, ggplot2, sampling)

two data frame

dta2 <- filter(dta, Field1 != "教育學群")
edu1 <- filter(dta, Field1 =="教育學群")

data construction

glimpse(dta)
## Observations: 1,724
## Variables: 24
## $ SID         <fctr> A1, A10, A100, A101, A102, A103, A104, A105, A106...
## $ Gender      <fctr> 女, 女, 女, 女, 女, 男, 女, 女, 女, 女, 女, 男, 女, 女, 男, 男, 男...
## $ Sector      <fctr> 國立(公立), 國立(公立), 私立, 國立(公立), 國立(公立), 國立(公立), 國立(公立...
## $ EduLv       <fctr> 碩士, 碩士, 普通大學, 碩士, 普通大學, 高職, 普通大學, 普通大學, 普通大學, 普通大...
## $ SubEduOver  <fctr> 符合工作要求, 高於工作要求, 符合工作要求, 符合工作要求, 符合工作要求, 符合工作要求, 符...
## $ Require     <fctr> 碩士, 高中/高職, 普通大學, 普通大學, 普通大學, 高中/高職, 普通大學, 普通大學, 普...
## $ Field1      <fctr> 教育學群, 資訊學群, 外語學群, 教育學群, 教育學群, 工程學群, 文史哲學群, 文史哲學群,...
## $ City        <fctr> 臺南市, 高雄市, 苗栗縣, 臺南市, 新北市, 高雄市, 南投縣, 嘉義市, 臺北市, 臺北市,...
## $ Category    <fctr> 受雇於公營機關, 受雇於公營機關, 受雇於公營機關, 受雇於公營機關, 受雇於公營機關, 受雇者於...
## $ Staff       <fctr> 10-29人, 50-99人, 50-99人, 50-99人, 10-29人, 2-9人, 100...
## $ Hours       <int> 48, 40, 70, 40, 50, 57, 51, 64, 50, 50, 47, 50, 40...
## $ J_year      <dbl> 2, 8, 4, 9, 1, 21, 1, 6, 0, 1, 1, 5, 1, 17, 7, 3, ...
## $ J_total     <dbl> 2, 8, 4, 9, 1, 30, 1, 6, 0, 2, 2, 5, 2, 28, 7, 30,...
## $ income      <fctr> 2萬以下, 2-3萬以下, 3-4萬以下, 4-5萬以下, 4-5萬以下, 3-4萬以下, 4-5...
## $ SubMismatch <int> 4, 2, 3, 4, 4, 5, 4, 5, 4, 3, 3, 4, 5, 4, 4, 4, 4,...
## $ JobSat      <int> 6, 4, 3, 4, 5, 5, 6, 7, 5, 3, 6, 5, 4, 3, 5, 4, 7,...
## $ EduZone     <int> 5, 5, 4, 5, 4, 2, 4, 4, 4, 4, 4, 5, 4, 5, 5, 3, 5,...
## $ Region      <fctr> 雲嘉南, 高屏澎, 桃竹苗, 雲嘉南, 北北基, 高屏澎, 中彰投, 雲嘉南, 北北基, 北北基,...
## $ Salary      <int> 20000, 25000, 35000, 45000, 45000, 35000, 45000, 2...
## $ Age         <int> 26, 34, 30, 34, 25, 62, 25, 21, 24, 25, 26, 29, 25...
## $ JobZone     <int> 4, 3, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,...
## $ JobCor      <int> 3, 1, 2, 3, 3, 1, 2, 1, 3, 1, 1, 3, 3, 1, 3, 1, 1,...
## $ Core        <fctr> 核心關聯, 無關聯, 無關聯, 核心關聯, 核心關聯, 無關聯, 無關聯, 無關聯, 核心關聯, ...
## $ ObjOver     <fctr> over, over, adequate, over, adequate, under, adeq...

教育群分層隨機抽樣

s <- strata(edu1, stratanames = "Region", size = c(18, 35, 15, 15, 15, 7))
## Warning in strata(edu1, stratanames = "Region", size = c(18, 35, 15, 15, :
## the method is not specified; by default, the method is srswor
edu2<- getdata(edu1, s) %>% dplyr::select( -c(25:27) )

cobine data

dta<- rbind(dta2, edu2)

view the plot

ggplot(dta, aes(Field1, fill = Region))+
  geom_bar()+
  coord_flip()+
  geom_text(stat = "count", aes(label = ..count.., y = ..count..), 
            position = position_stack(vjust = 0.5), size = rel(3))+
  labs(x = "Study Field")