此部分為醫院指標分析程式碼,主要分析內容為:

  1. 各醫院指標分布圖及box-plot

  2. 依醫院分級的醫院指標分布圖

library(ggplot2)
names(Hospital_Total_Index_merge)
##  [1] "醫事機構代碼"                                  
##  [2] "急救責任醫院等級"                              
##  [3] "年度季別"                                      
##  [4] "醫事機構名稱"                                  
##  [5] "縣市別"                                        
##  [6] "急性病床住院案件住院日數超過三十日比率"        
##  [7] "AMI病人出院後十四日以內非計畫性再住院比率_跨院"
##  [8] "AMI病人出院後十四日以內非計畫性再住院比率_同院"
##  [9] "AMI病人出院後三日急診返診比率_跨院"            
## [10] "住院之病例組合指標CMI值"                       
## [11] "DRG案件三日內再急診率"                         
## [12] "出院後三日以內同院所再急診率"                  
## [13] "非計畫性住院案件出院後十四日以內再住院率"      
## [14] "急診就診後同日於同醫院急診返診比率"            
## [15] "急診轉住院暫留急診超過四十八小時案件比率"
round(sapply(Hospital_Total_Index_merge[,6:15], function(x)sum(is.na(x)))/279,digits=3)
##         急性病床住院案件住院日數超過三十日比率 
##                                          0.000 
## AMI病人出院後十四日以內非計畫性再住院比率_跨院 
##                                          0.659 
## AMI病人出院後十四日以內非計畫性再住院比率_同院 
##                                          0.659 
##             AMI病人出院後三日急診返診比率_跨院 
##                                          0.659 
##                        住院之病例組合指標CMI值 
##                                          0.165 
##                          DRG案件三日內再急診率 
##                                          0.165 
##                   出院後三日以內同院所再急診率 
##                                          0.000 
##       非計畫性住院案件出院後十四日以內再住院率 
##                                          0.000 
##             急診就診後同日於同醫院急診返診比率 
##                                          0.000 
##       急診轉住院暫留急診超過四十八小時案件比率 
##                                          0.011
ggplot(aes(x = 出院後三日以內同院所再急診率), data = Hospital_Total_Index_merge) + 
  geom_histogram(bins = 15) + 
  scale_x_continuous(limits = c(0, 0.05), breaks = seq(0, 0.05, .005)) 
## Warning: Removed 2 rows containing non-finite values (stat_bin).

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   0.010   0.015   0.016   0.021   0.076
ggplot(aes(x = 出院後三日以內同院所再急診率), data = Hospital_Total_Index_merge) + 
  geom_histogram(bins = 15) + 
  scale_x_continuous(limits = c(0, 0.05), breaks = seq(0, 0.05, .005)) +       #將超過0.5視為離群值 
  facet_wrap(~急救責任醫院等級) #分成各類別
## Warning: Removed 2 rows containing non-finite values (stat_bin).

ggplot(aes(x = 出院後三日以內同院所再急診率), data = Hospital_Total_Index_merge) + 
  geom_freqpoly(aes(color = 急救責任醫院等級), bins = 15) + 
  scale_x_continuous(limits = c(0, 0.05), breaks = seq(0, 0.05, .005)) 
## Warning: Removed 2 rows containing non-finite values (stat_bin).
## Warning: Removed 6 rows containing missing values (geom_path).

qplot(x = 急救責任醫院等級, y = 出院後三日以內同院所再急診率,
      data = Hospital_Total_Index_merge, geom = "boxplot") +
      stat_summary(fun.y = mean, geom = "point", shape = 4)

by(Hospital_Total_Index_merge$出院後三日以內同院所再急診率, Hospital_Total_Index_merge$急救責任醫院等級, summary)
## Hospital_Total_Index_merge$急救責任醫院等級: 一般
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## 0.000000 0.004775 0.012100 0.015639 0.025500 0.076200 
## -------------------------------------------------------- 
## Hospital_Total_Index_merge$急救責任醫院等級: 中度
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.00000 0.01490 0.01760 0.01829 0.02050 0.03610 
## -------------------------------------------------------- 
## Hospital_Total_Index_merge$急救責任醫院等級: 重度
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.0088  0.0124  0.0145  0.0152  0.0175  0.0228