library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.5.3
## -- Attaching packages ---------------------------------------------------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.1.1 v purrr 0.3.2
## v tibble 2.1.1 v dplyr 0.8.1
## v tidyr 0.8.3 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## Warning: package 'ggplot2' was built under R version 3.5.3
## Warning: package 'tibble' was built under R version 3.5.3
## Warning: package 'tidyr' was built under R version 3.5.3
## Warning: package 'readr' was built under R version 3.5.3
## Warning: package 'purrr' was built under R version 3.5.3
## Warning: package 'dplyr' was built under R version 3.5.3
## Warning: package 'stringr' was built under R version 3.5.3
## Warning: package 'forcats' was built under R version 3.5.3
## -- Conflicts ------------------------------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(readxl)
## Warning: package 'readxl' was built under R version 3.5.3
library(ggplot2)
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 3.5.3
library(DescTools)
## Warning: package 'DescTools' was built under R version 3.5.3
library(moonBook)
library(lubridate)
## Warning: package 'lubridate' was built under R version 3.5.3
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
library(caret)
## Warning: package 'caret' was built under R version 3.5.3
## Loading required package: lattice
##
## Attaching package: 'lattice'
## The following object is masked from 'package:moonBook':
##
## densityplot
##
## Attaching package: 'caret'
## The following objects are masked from 'package:DescTools':
##
## MAE, RMSE
## The following object is masked from 'package:purrr':
##
## lift
### doc du lieu vao My computer Work
#wait_time <- read_excel("D:/Google Driver/benh vien/thoi gian cho/thoi gian cho 12-8.xlsx")
### home destop
wait_time <- read_excel("C:/Users/Dr Long/Google Drive/benh vien/thoi gian cho/thoi gian cho 12-8.xlsx")
wait <- as_tibble(wait_time) # chuyen du lieu ve dang data frame
wait1 <- distinct(wait) # loai bo cac bien trung nhau
wait2 <- wait1
wait2$thu <- as.factor(wait2$thu)
wait2$diachi <- as.factor(wait2$diachi)
wait2$loaikham <- as.factor(wait2$loaikham)
wait2$Dky_tongdai <- as.factor(wait2$Dky_tongdai)
wait2$Trong_ngay <- as.factor(wait2$Trong_ngay)
wait2$nhom_t1 <- as.factor(wait2$nhom_t1)
wait2$cho_phatso <- hour(wait2$t2_nhanB) + minute(wait2$t2_nhanB)/60 - (hour(wait2$t1_phatso) + minute(wait2$t1_phatso)/60)
wait2$cho_nhanbenh <- hour(wait2$t3_dongT) + minute(wait2$t3_dongT)/60 - (hour(wait2$t2_nhanB) + minute(wait2$t2_nhanB)/60)
wait2$cho_dongtien <- hour(wait2$t4_kham_sta) + minute(wait2$t4_kham_sta)/60 - (hour(wait2$t3_dongT) + minute(wait2$t3_dongT)/60)
wait2$cho_kham_SA <- hour(wait2$t5_CD_SA) + minute(wait2$t5_CD_SA)/60 - (hour(wait2$t4_kham_sta) + minute(wait2$t4_kham_sta)/60)
wait2$cho_SA_end <- hour(wait2$t6_SA_end) + minute(wait2$t6_SA_end)/60 - (hour(wait2$t5_CD_SA) + minute(wait2$t5_CD_SA)/60)
wait2$cho_kham_XN <- hour(wait2$t5b_CD_XN) + minute(wait2$t5b_CD_XN)/60 - (hour(wait2$t4_kham_sta) + minute(wait2$t4_kham_sta)/60)
wait2$cho_XN_tiepnhan_CD <- hour(wait2$t6b_tiepnhan_XN) + minute(wait2$t6b_tiepnhan_XN)/60 - (hour(wait2$t5b_CD_XN) + minute(wait2$t5b_CD_XN)/60)
wait2$cho_XN_KQ_tiepnhan <- hour(wait2$t7_traKQ_XN) + minute(wait2$t7_traKQ_XN)/60 - (hour(wait2$t6b_tiepnhan_XN) + minute(wait2$t6b_tiepnhan_XN)/60)
wait2$cho_XN_ketthuc_XN <- hour(wait2$t8_kham_end) + minute(wait2$t8_kham_end)/60 - (hour(wait2$t7_traKQ_XN) + minute(wait2$t7_traKQ_XN)/60)
wait2$cho_XN_ketthuc_SA <- hour(wait2$t8_kham_end) + minute(wait2$t8_kham_end)/60 - (hour(wait2$t6_SA_end) + minute(wait2$t6_SA_end)/60)
summary(wait2)
## ngayNV ngay thu id
## Min. :20190301 Min. : 1.00 CN: 35 Min. : 1
## 1st Qu.:20190304 1st Qu.: 4.00 T2:446 1st Qu.: 395
## Median :20190313 Median :13.00 T3:194 Median : 789
## Mean :20190314 Mean :14.02 T4:203 Mean : 789
## 3rd Qu.:20190322 3rd Qu.:22.00 T5:250 3rd Qu.:1183
## Max. :20190331 Max. :31.00 T6:255 Max. :1577
## T7:194
## stt diachi loaikham Dky_tongdai
## Min. :1.400e+09 thanhpho: 397 cu :1078 co : 28
## 1st Qu.:1.800e+09 tinh :1180 moi: 499 khong:1549
## Median :1.900e+09
## Mean :1.833e+09
## 3rd Qu.:1.900e+09
## Max. :1.900e+09
##
## t1_phatso t2_nhanB
## Min. :1899-12-31 05:48:00 Min. :1899-12-31 05:57:00
## 1st Qu.:1899-12-31 06:24:00 1st Qu.:1899-12-31 07:52:00
## Median :1899-12-31 07:40:00 Median :1899-12-31 09:22:00
## Mean :1899-12-31 08:10:17 Mean :1899-12-31 10:18:48
## 3rd Qu.:1899-12-31 09:35:00 3rd Qu.:1899-12-31 12:39:00
## Max. :1899-12-31 14:03:00 Max. :1899-12-31 17:48:00
## NA's :102
## t3_dongT t4_kham_sta
## Min. :1899-12-31 06:19:00 Min. :1899-12-31 06:52:00
## 1st Qu.:1899-12-31 07:58:00 1st Qu.:1899-12-31 08:35:00
## Median :1899-12-31 09:34:00 Median :1899-12-31 10:21:00
## Mean :1899-12-31 10:28:32 Mean :1899-12-31 11:19:40
## 3rd Qu.:1899-12-31 12:46:00 3rd Qu.:1899-12-31 13:57:00
## Max. :1899-12-31 17:50:00 Max. :1899-12-31 19:06:00
## NA's :167
## t5_CD_SA t6_SA_end
## Min. :1899-12-31 07:04:00 Min. :1899-12-31 07:34:00
## 1st Qu.:1899-12-31 08:57:00 1st Qu.:1899-12-31 10:11:00
## Median :1899-12-31 10:41:00 Median :1899-12-31 12:08:00
## Mean :1899-12-31 11:39:01 Mean :1899-12-31 12:40:41
## 3rd Qu.:1899-12-31 14:14:00 3rd Qu.:1899-12-31 15:07:00
## Max. :1899-12-31 19:16:00 Max. :1899-12-31 19:26:00
## NA's :4
## t5b_CD_XN t6b_tiepnhan_XN
## Min. :1899-12-31 07:04:00 Min. :1899-12-31 07:19:00
## 1st Qu.:1899-12-31 09:08:00 1st Qu.:1899-12-31 09:36:00
## Median :1899-12-31 11:06:00 Median :1899-12-31 11:37:00
## Mean :1899-12-31 11:54:25 Mean :1899-12-31 12:11:57
## 3rd Qu.:1899-12-31 14:23:00 3rd Qu.:1899-12-31 14:32:15
## Max. :1899-12-31 19:31:00 Max. :1899-12-31 19:34:00
## NA's :9
## t7_traKQ_XN t8_kham_end
## Min. :1899-12-31 08:19:00 Min. :1899-12-31 07:12:00
## 1st Qu.:1899-12-31 10:40:45 1st Qu.:1899-12-31 11:38:00
## Median :1899-12-31 12:28:00 Median :1899-12-31 13:46:00
## Mean :1899-12-31 13:11:07 Mean :1899-12-31 13:53:11
## 3rd Qu.:1899-12-31 15:40:00 3rd Qu.:1899-12-31 16:06:00
## Max. :1899-12-31 20:16:00 Max. :1899-12-31 19:48:00
## NA's :9
## maxtg thoi_cho
## Min. :1899-12-31 08:19:00 Min. :1899-12-31 02:38:00
## 1st Qu.:1899-12-31 11:02:00 1st Qu.:1899-12-31 08:40:00
## Median :1899-12-31 13:10:00 Median :1899-12-31 13:47:00
## Mean :1899-12-31 13:30:51 Mean :1899-12-31 17:36:43
## 3rd Qu.:1899-12-31 15:54:00 3rd Qu.:1900-01-01 03:04:00
## Max. :1899-12-31 20:16:00 Max. :1900-01-01 16:05:00
##
## Trong_ngay thoi_cho_gio nhom_t1 cho_phatso
## quangay :747 Min. :-4.817 b_tr6-7g :544 Min. :0.3333
## trongngay:830 1st Qu.: 3.367 e_tr9-10g :229 1st Qu.:1.2583
## Median : 5.950 c_tr7-8g :210 Median :1.9500
## Mean : 6.243 d_tr8-9g :165 Mean :2.2408
## 3rd Qu.: 9.200 f_tr10-11g:139 3rd Qu.:3.0167
## Max. :19.000 (Other) :188 Max. :6.1167
## NA's :102 NA's :102
## cho_nhanbenh cho_dongtien cho_kham_SA cho_SA_end
## Min. :0.00000 Min. :-6.0667 Min. :-5.3000 Min. :0.1000
## 1st Qu.:0.06667 1st Qu.: 0.3667 1st Qu.: 0.1667 1st Qu.:0.5667
## Median :0.10000 Median : 0.7333 Median : 0.2500 Median :0.9000
## Mean :0.14307 Mean : 0.8543 Mean : 0.3224 Mean :1.0346
## 3rd Qu.:0.16667 3rd Qu.: 1.2333 3rd Qu.: 0.3833 3rd Qu.:1.3333
## Max. :4.11667 Max. : 4.1667 Max. : 7.6000 Max. :6.7167
## NA's :167 NA's :167 NA's :4
## cho_kham_XN cho_XN_tiepnhan_CD cho_XN_KQ_tiepnhan
## Min. :-5.3000 Min. :0.01667 Min. :-10.0667
## 1st Qu.: 0.2000 1st Qu.:0.10000 1st Qu.: 0.7500
## Median : 0.2833 Median :0.18333 Median : 1.5000
## Mean : 0.5792 Mean :0.31688 Mean : 0.9859
## 3rd Qu.: 0.5500 3rd Qu.:0.38333 3rd Qu.: 1.5000
## Max. : 6.4667 Max. :5.25000 Max. : 3.0000
## NA's :9 NA's :9
## cho_XN_ketthuc_XN cho_XN_ketthuc_SA
## Min. :-10.5333 Min. :-10.000
## 1st Qu.: -2.4042 1st Qu.: -1.800
## Median : 0.6250 Median : 1.133
## Mean : 0.7066 Mean : 1.214
## 3rd Qu.: 3.7167 3rd Qu.: 4.283
## Max. : 10.7167 Max. : 10.783
## NA's :9 NA's :4
S??? lý???ng b???nh nhân h???n qua ngà y 646 TH/1577 TH quá cao, do ðó chúng ta c???n so sánh các y???u t??? ???nh hý???ng ð???n 2 nhóm trong ngà y và qua ngà y
attach(wait2)
sosanh <- data.frame(Trong_ngay, ngay , thu , diachi , loaikham , Dky_tongdai ,
cho_phatso , cho_nhanbenh , cho_dongtien , cho_kham_SA , cho_SA_end ,
cho_kham_XN , cho_XN_tiepnhan_CD , cho_XN_KQ_tiepnhan ,
cho_XN_ketthuc_XN , cho_XN_ketthuc_SA ,
thoi_cho_gio , nhom_t1)
mytable(Trong_ngay ~ . ,data=sosanh)
##
## Descriptive Statistics by 'Trong_ngay'
## _________________________________________________
## quangay trongngay p
## (N=747) (N=830)
## -------------------------------------------------
## ngay 14.1 ± 8.8 14.0 ± 9.6 0.740
## thu 0.000
## - CN 3 ( 0.4%) 32 ( 3.9%)
## - T2 229 (30.7%) 217 (26.1%)
## - T3 101 (13.5%) 93 (11.2%)
## - T4 118 (15.8%) 85 (10.2%)
## - T5 124 (16.6%) 126 (15.2%)
## - T6 101 (13.5%) 154 (18.6%)
## - T7 71 ( 9.5%) 123 (14.8%)
## diachi 0.000
## - thanhpho 235 (31.5%) 162 (19.5%)
## - tinh 512 (68.5%) 668 (80.5%)
## loaikham 0.000
## - cu 469 (62.8%) 609 (73.4%)
## - moi 278 (37.2%) 221 (26.6%)
## Dky_tongdai 0.771
## - co 12 ( 1.6%) 16 ( 1.9%)
## - khong 735 (98.4%) 814 (98.1%)
## cho_phatso 2.9 ± 1.3 1.7 ± 0.9 0.000
## cho_nhanbenh 0.1 ± 0.3 0.2 ± 0.1 0.002
## cho_dongtien 1.0 ± 0.8 0.7 ± 0.6 0.000
## cho_kham_SA 0.3 ± 0.4 0.3 ± 0.3 0.423
## cho_SA_end 0.9 ± 0.7 1.1 ± 0.6 0.000
## cho_kham_XN 0.6 ± 0.9 0.5 ± 0.7 0.012
## cho_XN_tiepnhan_CD 0.3 ± 0.3 0.4 ± 0.4 0.000
## cho_XN_KQ_tiepnhan 0.8 ± 2.0 1.2 ± 0.5 0.000
## cho_XN_ketthuc_XN -2.7 ± 2.7 3.7 ± 2.5 0.000
## cho_XN_ketthuc_SA -2.3 ± 2.4 4.4 ± 2.5 0.000
## thoi_cho_gio 3.3 ± 3.0 8.9 ± 2.9 0.000
## nhom_t1 0.000
## - a_tr5-6g 5 ( 0.7%) 46 ( 6.0%)
## - b_tr6-7g 120 (16.8%) 424 (55.7%)
## - c_tr7-8g 88 (12.3%) 122 (16.0%)
## - d_tr8-9g 96 (13.4%) 69 ( 9.1%)
## - e_tr9-10g 166 (23.2%) 63 ( 8.3%)
## - f_tr10-11g 109 (15.3%) 30 ( 3.9%)
## - g_tr11-12g 63 ( 8.8%) 4 ( 0.5%)
## - h_tr12-13g 35 ( 4.9%) 3 ( 0.4%)
## - i_tr13-14g 30 ( 4.2%) 0 ( 0.0%)
## - j_tr14g-15g 2 ( 0.3%) 0 ( 0.0%)
## -------------------------------------------------
Các y???u t??? ???nh hý???ng ð???n khám qua ngà y bao g???m: Th??? khám b???nh, ð???a ch???, th???i gian ch??? phát s???, ch??? nh???n b???nh, ch??? ðóng ti???n, siêu âm, khám ð???n XN, ti???p nh???n XN, nh???n k???t qu???, k???t thúc XN, k???t thúc siêu âm,nhóm th???i gian b???t ð???u l???y s???.
Tuy nhiên c???n phân tÃch ???nh hý???ng týõng tác các y???u t??? nà y v???i nhau và khâu nà o quan tr???ng nh???t trong vi???c BN khám qua ngà y:
wait2 <- na.omit(wait2) # bo du lieu trong tu 1577 ca giam con 1357 TH
attach(wait2)
## The following objects are masked from wait2 (pos = 3):
##
## cho_dongtien, cho_kham_SA, cho_kham_XN, cho_nhanbenh,
## cho_phatso, cho_SA_end, cho_XN_ketthuc_SA, cho_XN_ketthuc_XN,
## cho_XN_KQ_tiepnhan, cho_XN_tiepnhan_CD, diachi, Dky_tongdai,
## id, loaikham, maxtg, ngay, ngayNV, nhom_t1, stt, t1_phatso,
## t2_nhanB, t3_dongT, t4_kham_sta, t5_CD_SA, t5b_CD_XN,
## t6_SA_end, t6b_tiepnhan_XN, t7_traKQ_XN, t8_kham_end,
## thoi_cho, thoi_cho_gio, thu, Trong_ngay
sosanh <- data.frame(Trong_ngay, ngay , thu , diachi , loaikham , Dky_tongdai ,
cho_phatso , cho_nhanbenh , cho_dongtien , cho_kham_SA , cho_SA_end ,
cho_kham_XN , cho_XN_tiepnhan_CD , cho_XN_KQ_tiepnhan ,
cho_XN_ketthuc_XN , cho_XN_ketthuc_SA ,
thoi_cho_gio , nhom_t1)
names(sosanh)
## [1] "Trong_ngay" "ngay" "thu"
## [4] "diachi" "loaikham" "Dky_tongdai"
## [7] "cho_phatso" "cho_nhanbenh" "cho_dongtien"
## [10] "cho_kham_SA" "cho_SA_end" "cho_kham_XN"
## [13] "cho_XN_tiepnhan_CD" "cho_XN_KQ_tiepnhan" "cho_XN_ketthuc_XN"
## [16] "cho_XN_ketthuc_SA" "thoi_cho_gio" "nhom_t1"
summary(sosanh)
## Trong_ngay ngay thu diachi loaikham
## quangay :646 Min. : 1.00 CN: 35 thanhpho: 351 cu :969
## trongngay:711 1st Qu.: 7.00 T2:226 tinh :1006 moi:388
## Median :15.00 T3:194
## Mean :15.65 T4:203
## 3rd Qu.:23.00 T5:250
## Max. :31.00 T6:255
## T7:194
## Dky_tongdai cho_phatso cho_nhanbenh cho_dongtien
## co : 5 Min. :0.3333 Min. :0.00000 Min. :-6.0667
## khong:1352 1st Qu.:1.2167 1st Qu.:0.06667 1st Qu.: 0.3667
## Median :1.8500 Median :0.10000 Median : 0.7167
## Mean :2.2046 Mean :0.13645 Mean : 0.8457
## 3rd Qu.:2.9667 3rd Qu.:0.16667 3rd Qu.: 1.2333
## Max. :6.1167 Max. :4.11667 Max. : 4.1667
##
## cho_kham_SA cho_SA_end cho_kham_XN cho_XN_tiepnhan_CD
## Min. :-5.3000 Min. :0.1000 Min. :-5.3000 Min. :0.01667
## 1st Qu.: 0.1833 1st Qu.:0.5667 1st Qu.: 0.2000 1st Qu.:0.10000
## Median : 0.2667 Median :0.9167 Median : 0.3000 Median :0.18333
## Mean : 0.3276 Mean :1.0538 Mean : 0.6018 Mean :0.30591
## 3rd Qu.: 0.4000 3rd Qu.:1.3667 3rd Qu.: 0.5500 3rd Qu.:0.36667
## Max. : 7.6000 Max. :6.7167 Max. : 6.4667 Max. :5.25000
##
## cho_XN_KQ_tiepnhan cho_XN_ketthuc_XN cho_XN_ketthuc_SA thoi_cho_gio
## Min. :-10.0667 Min. :-10.5333 Min. :-10.000 Min. :-4.817
## 1st Qu.: 0.7500 1st Qu.: -2.4000 1st Qu.: -1.850 1st Qu.: 3.200
## Median : 1.5000 Median : 0.5833 Median : 1.050 Median : 5.617
## Mean : 0.9573 Mean : 0.7089 Mean : 1.193 Mean : 5.761
## 3rd Qu.: 1.5000 3rd Qu.: 3.7333 3rd Qu.: 4.283 3rd Qu.: 8.717
## Max. : 3.0000 Max. : 10.7167 Max. : 10.783 Max. :13.600
##
## nhom_t1
## b_tr6-7g :498
## e_tr9-10g :210
## c_tr7-8g :189
## d_tr8-9g :151
## f_tr10-11g:132
## g_tr11-12g: 60
## (Other) :117
########## tim cac khau lien quan den qua ngay ###############
sosanh2 <- data.frame(Trong_ngay, ngay , thu , diachi , loaikham , Dky_tongdai ,
cho_phatso , cho_nhanbenh , cho_dongtien , cho_kham_SA , cho_SA_end ,
cho_kham_XN , cho_XN_tiepnhan_CD , cho_XN_KQ_tiepnhan ,
cho_XN_ketthuc_XN , cho_XN_ketthuc_SA ,
nhom_t1)
t <- glm(formula = Trong_ngay ~ cho_phatso + cho_dongtien +
cho_SA_end + cho_XN_KQ_tiepnhan + cho_XN_ketthuc_XN ,
family = binomial, data = sosanh2)
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
mod_fit <- train(Trong_ngay ~ cho_phatso + cho_dongtien +
cho_SA_end + cho_XN_KQ_tiepnhan + cho_XN_ketthuc_XN,
data = sosanh2, method = "glm", family = "binomial")
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
pred <- predict(mod_fit, newdata = sosanh2)
confusionMatrix(data = pred, sosanh2$Trong_ngay)
## Confusion Matrix and Statistics
##
## Reference
## Prediction quangay trongngay
## quangay 624 18
## trongngay 22 693
##
## Accuracy : 0.9705
## 95% CI : (0.9601, 0.9789)
## No Information Rate : 0.5239
## P-Value [Acc > NIR] : <2e-16
##
## Kappa : 0.9409
##
## Mcnemar's Test P-Value : 0.6353
##
## Sensitivity : 0.9659
## Specificity : 0.9747
## Pos Pred Value : 0.9720
## Neg Pred Value : 0.9692
## Prevalence : 0.4761
## Detection Rate : 0.4598
## Detection Prevalence : 0.4731
## Balanced Accuracy : 0.9703
##
## 'Positive' Class : quangay
##
library(caret)
varImp(mod_fit)
## glm variable importance
##
## Overall
## cho_XN_ketthuc_XN 100.00
## cho_XN_KQ_tiepnhan 94.20
## cho_SA_end 26.62
## cho_dongtien 23.49
## cho_phatso 0.00
## cac bien quan trong anh huong den kham qua ngay
plot(varImp(mod_fit))
Qua phân tÃch ða bi???n cho th???y k???t thúc xét nghi???m và tr??? k???t qu??? XN ???nh hý???ng chÃnh ð???n h???n khám qua ngà y.
wait_trongngay <- subset(wait2, wait2$Trong_ngay == 'trongngay') # ch???n các trý???ng h???p trong ngà y
names(wait_trongngay)
## [1] "ngayNV" "ngay" "thu"
## [4] "id" "stt" "diachi"
## [7] "loaikham" "Dky_tongdai" "t1_phatso"
## [10] "t2_nhanB" "t3_dongT" "t4_kham_sta"
## [13] "t5_CD_SA" "t6_SA_end" "t5b_CD_XN"
## [16] "t6b_tiepnhan_XN" "t7_traKQ_XN" "t8_kham_end"
## [19] "maxtg" "thoi_cho" "Trong_ngay"
## [22] "thoi_cho_gio" "nhom_t1" "cho_phatso"
## [25] "cho_nhanbenh" "cho_dongtien" "cho_kham_SA"
## [28] "cho_SA_end" "cho_kham_XN" "cho_XN_tiepnhan_CD"
## [31] "cho_XN_KQ_tiepnhan" "cho_XN_ketthuc_XN" "cho_XN_ketthuc_SA"
detach(wait2)
attach(wait_trongngay)
## The following objects are masked from wait2:
##
## cho_dongtien, cho_kham_SA, cho_kham_XN, cho_nhanbenh,
## cho_phatso, cho_SA_end, cho_XN_ketthuc_SA, cho_XN_ketthuc_XN,
## cho_XN_KQ_tiepnhan, cho_XN_tiepnhan_CD, diachi, Dky_tongdai,
## id, loaikham, maxtg, ngay, ngayNV, nhom_t1, stt, t1_phatso,
## t2_nhanB, t3_dongT, t4_kham_sta, t5_CD_SA, t5b_CD_XN,
## t6_SA_end, t6b_tiepnhan_XN, t7_traKQ_XN, t8_kham_end,
## thoi_cho, thoi_cho_gio, thu, Trong_ngay
head(wait_trongngay)
## # A tibble: 6 x 33
## ngayNV ngay thu id stt diachi loaikham Dky_tongdai
## <dbl> <dbl> <fct> <dbl> <dbl> <fct> <fct> <fct>
## 1 2.02e7 12 T3 725 1.90e9 tinh cu khong
## 2 2.02e7 12 T3 726 1.90e9 tinh cu khong
## 3 2.02e7 12 T3 727 1.90e9 tinh cu khong
## 4 2.02e7 12 T3 728 1.90e9 tinh cu khong
## 5 2.02e7 2 T7 70 1.90e9 tinh cu khong
## 6 2.02e7 12 T3 707 1.40e9 tinh moi khong
## # ... with 25 more variables: t1_phatso <dttm>, t2_nhanB <dttm>,
## # t3_dongT <dttm>, t4_kham_sta <dttm>, t5_CD_SA <dttm>,
## # t6_SA_end <dttm>, t5b_CD_XN <dttm>, t6b_tiepnhan_XN <dttm>,
## # t7_traKQ_XN <dttm>, t8_kham_end <dttm>, maxtg <dttm>, thoi_cho <dttm>,
## # Trong_ngay <fct>, thoi_cho_gio <dbl>, nhom_t1 <fct>, cho_phatso <dbl>,
## # cho_nhanbenh <dbl>, cho_dongtien <dbl>, cho_kham_SA <dbl>,
## # cho_SA_end <dbl>, cho_kham_XN <dbl>, cho_XN_tiepnhan_CD <dbl>,
## # cho_XN_KQ_tiepnhan <dbl>, cho_XN_ketthuc_XN <dbl>,
## # cho_XN_ketthuc_SA <dbl>
# tinh thoi gia cho trung binh trong ngay va ve hinh
summary(wait_trongngay$thoi_cho_gio)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2.633 6.608 8.567 8.383 10.033 13.600
names(wait_trongngay)
## [1] "ngayNV" "ngay" "thu"
## [4] "id" "stt" "diachi"
## [7] "loaikham" "Dky_tongdai" "t1_phatso"
## [10] "t2_nhanB" "t3_dongT" "t4_kham_sta"
## [13] "t5_CD_SA" "t6_SA_end" "t5b_CD_XN"
## [16] "t6b_tiepnhan_XN" "t7_traKQ_XN" "t8_kham_end"
## [19] "maxtg" "thoi_cho" "Trong_ngay"
## [22] "thoi_cho_gio" "nhom_t1" "cho_phatso"
## [25] "cho_nhanbenh" "cho_dongtien" "cho_kham_SA"
## [28] "cho_SA_end" "cho_kham_XN" "cho_XN_tiepnhan_CD"
## [31] "cho_XN_KQ_tiepnhan" "cho_XN_ketthuc_XN" "cho_XN_ketthuc_SA"
Desc(wait_trongngay$thoi_cho_gio) # t??? lúc phát s??? d???n khi k???t thúc
## -------------------------------------------------------------------------
## wait_trongngay$thoi_cho_gio (numeric)
##
## length n NAs unique 0s
## 7e+02 7e+02 0 5e+02 0
## 100.0% 0.0% 0.0%
##
## .05 .10 .25 median .75
## 4.308333e+00 5.066667e+00 6.608333e+00 8.566667e+00 1.003333e+01
##
## range sd vcoef mad IQR
## 1.096667e+01 2.341653e+00 2.793295e-01 2.421580e+00 3.425000e+00
##
## mean meanCI
## 8.383122e+00 8.210707e+00
## 8.555538e+00
##
## .90 .95
## 1.150000e+01 1.225833e+01
##
## skew kurt
## -9.979104e-02 -7.267577e-01
##
## lowest : 2.633333e+00, 3.266667e+00, 3.433333e+00, 3.516667e+00, 3.566667e+00
## highest: 1.310000e+01, 1.335000e+01, 1.345000e+01, 1.353333e+01, 1.360000e+01
Desc(wait_trongngay$cho_phatso)
## -------------------------------------------------------------------------
## wait_trongngay$cho_phatso (numeric)
##
## length n NAs unique
## 7e+02 7e+02 0 3e+02
## 100.0% 0.0%
##
## .05 .10 .25 median
## 6.7500000e-01 7.6666667e-01 1.0000000e+00 1.4833333e+00
##
## range sd vcoef mad
## 5.5666667e+00 8.6945980e-01 5.2869541e-01 7.6601000e-01
##
## 0s mean meanCI
## 0 1.6445382e+00 1.5805200e+00
## 0.0% 1.7085565e+00
##
## .75 .90 .95
## 2.0500000e+00 2.8166667e+00 3.4000000e+00
##
## IQR skew kurt
## 1.0500000e+00 1.3686792e+00 2.3097301e+00
##
## lowest : 3.3333333e-01, 3.6666667e-01, 4.3333333e-01, 4.5000000e-01, 4.6666667e-01
## highest: 4.7833333e+00, 4.9000000e+00, 5.3333333e+00, 5.7000000e+00, 5.9000000e+00
Desc(wait_trongngay$cho_nhanbenh)
## -------------------------------------------------------------------------
## wait_trongngay$cho_nhanbenh (numeric)
##
## length n NAs unique
## 7e+02 7e+02 0 8e+01
## 100.0% 0.0%
##
## .05 .10 .25 median
## 3.33333333e-02 5.00000000e-02 6.66666667e-02 1.16666667e-01
##
## range sd vcoef mad
## 1.13333333e+00 1.27608786e-01 8.41389617e-01 7.41300000e-02
##
## 0s mean meanCI
## 0 1.51664323e-01 1.42268499e-01
## 0.0% 1.61060146e-01
##
## .75 .90 .95
## 1.83333333e-01 2.83333333e-01 4.00000000e-01
##
## IQR skew kurt
## 1.16666667e-01 2.65385970e+00 1.02493377e+01
##
## lowest : 1.66666667e-02 (2e+00), 1.66666667e-02, 1.66666667e-02, 3.33333333e-02 (4e+01), 3.33333333e-02
## highest: 7.33333333e-01, 7.50000000e-01, 7.83333333e-01, 8.16666667e-01, 1.15000000e+00
Desc(wait_trongngay$cho_dongtien)
## -------------------------------------------------------------------------
## wait_trongngay$cho_dongtien (numeric)
##
## length n NAs unique
## 7e+02 7e+02 0 2e+02
## 100.0% 0.0%
##
## .05 .10 .25 median
## 1.5000000e-01 2.0000000e-01 3.1666667e-01 5.6666667e-01
##
## range sd vcoef mad
## 4.6000000e+00 5.5990153e-01 7.8433650e-01 4.4478000e-01
##
## 0s mean meanCI
## 0 7.1385373e-01 6.7262823e-01
## 0.0% 7.5507923e-01
##
## .75 .90 .95
## 9.5000000e-01 1.4333333e+00 1.8083333e+00
##
## IQR skew kurt
## 6.3333333e-01 1.4832992e+00 3.2638262e+00
##
## lowest : -1.3000000e+00, -4.6666667e-01, -3.8333333e-01, -2.8333333e-01, -2.1666667e-01 (2e+00)
## highest: 2.9166667e+00, 2.9333333e+00, 3.0500000e+00, 3.2666667e+00, 3.3000000e+00
Desc(wait_trongngay$cho_kham_SA)
## -------------------------------------------------------------------------
## wait_trongngay$cho_kham_SA (numeric)
##
## length n NAs unique
## 7e+02 7e+02 0 1e+02
## 100.0% 0.0%
##
## .05 .10 .25 median
## 1.1666667e-01 1.5000000e-01 2.0000000e-01 2.8333333e-01
##
## range sd vcoef mad
## 7.0166667e+00 3.2366620e-01 9.7808318e-01 1.4826000e-01
##
## 0s mean meanCI
## 0 3.3091889e-01 3.0708738e-01
## 0.0% 3.5475041e-01
##
## .75 .90 .95
## 4.0000000e-01 6.1666667e-01 8.0000000e-01
##
## IQR skew kurt
## 2.0000000e-01 -7.1309832e+00 1.3149746e+02
##
## lowest : -5.3000000e+00, -1.9166667e+00, -5.0000000e-01, -3.6666667e-01, 5.0000000e-02
## highest: 1.3833333e+00, 1.4500000e+00, 1.4666667e+00, 1.5333333e+00, 1.7166667e+00
Desc(wait_trongngay$cho_SA_end)
## -------------------------------------------------------------------------
## wait_trongngay$cho_SA_end (numeric)
##
## length n NAs unique
## 7e+02 7e+02 0 3e+02
## 100.0% 0.0%
##
## .05 .10 .25 median
## 4.0000000e-01 5.1666667e-01 7.3333333e-01 1.0500000e+00
##
## range sd vcoef mad
## 4.9500000e+00 6.1081190e-01 5.2456487e-01 5.4362000e-01
##
## 0s mean meanCI
## 0 1.1644163e+00 1.1194423e+00
## 0.0% 1.2093903e+00
##
## .75 .90 .95
## 1.5000000e+00 1.9166667e+00 2.2833333e+00
##
## IQR skew kurt
## 7.6666667e-01 1.3831494e+00 3.7737813e+00
##
## lowest : 1.6666667e-01, 1.8333333e-01 (2e+00), 2.0000000e-01 (2e+00), 2.3333333e-01, 2.6666667e-01
## highest: 3.5500000e+00, 3.5833333e+00, 3.9333333e+00, 3.9666667e+00, 5.1166667e+00
Desc(wait_trongngay$cho_kham_XN)
## -------------------------------------------------------------------------
## wait_trongngay$cho_kham_XN (numeric)
##
## length n NAs unique
## 7e+02 7e+02 0 2e+02
## 100.0% 0.0%
##
## .05 .10 .25 median
## 1.3333333e-01 1.5000000e-01 2.1666667e-01 3.0000000e-01
##
## range sd vcoef mad
## 1.0000000e+01 7.7332601e-01 1.3906959e+00 1.7297000e-01
##
## 0s mean meanCI
## 0 5.5607126e-01 4.9913134e-01
## 0.0% 6.1301118e-01
##
## .75 .90 .95
## 5.1666667e-01 1.4833333e+00 2.4500000e+00
##
## IQR skew kurt
## 3.0000000e-01 1.8452394e+00 1.1231071e+01
##
## lowest : -5.3000000e+00, -1.8500000e+00, -3.6666667e-01, 5.0000000e-02, 6.6666667e-02
## highest: 3.9666667e+00, 4.2333333e+00, 4.3000000e+00, 4.6333333e+00, 4.7000000e+00
Desc(wait_trongngay$cho_XN_tiepnhan_CD)
## -------------------------------------------------------------------------
## wait_trongngay$cho_XN_tiepnhan_CD (numeric)
##
## length n NAs unique
## 7e+02 7e+02 0 2e+02
## 100.0% 0.0%
##
## .05 .10 .25 median
## 6.66666667e-02 8.33333333e-02 1.33333333e-01 2.50000000e-01
##
## range sd vcoef mad
## 5.23333333e+00 3.94216147e-01 1.07616694e+00 1.97680000e-01
##
## 0s mean meanCI
## 0 3.66315049e-01 3.37288950e-01
## 0.0% 3.95341148e-01
##
## .75 .90 .95
## 4.33333333e-01 7.66666667e-01 1.02500000e+00
##
## IQR skew kurt
## 3.00000000e-01 4.41786268e+00 3.73619747e+01
##
## lowest : 1.66666667e-02, 1.66666667e-02 (2e+00), 3.33333333e-02, 5.00000000e-02 (6e+00), 5.00000000e-02 (2e+01)
## highest: 2.00000000e+00, 2.11666667e+00, 2.33333333e+00, 2.81666667e+00, 5.25000000e+00
Desc(wait_trongngay$cho_XN_KQ_tiepnhan)
## -------------------------------------------------------------------------
## wait_trongngay$cho_XN_KQ_tiepnhan (numeric)
##
## length n NAs unique 0s
## 7e+02 7e+02 0 3e+01 0
## 100.0% 0.0% 0.0%
##
## .05 .10 .25 median .75
## 7.500000e-01 7.500000e-01 7.500000e-01 1.500000e+00 1.500000e+00
##
## range sd vcoef mad IQR
## 8.116667e+00 4.599110e-01 3.910275e-01 1.316813e-15 7.500000e-01
##
## mean meanCI
## 1.176160e+00 1.142297e+00
## 1.210024e+00
##
## .90 .95
## 1.500000e+00 1.500000e+00
##
## skew kurt
## -4.455822e+00 5.312777e+01
##
## lowest : -5.116667e+00, -2.183333e+00, -1.650000e+00, 1.166667e-01, 5.666667e-01
## highest: 1.500000e+00 (5e+00), 1.516667e+00, 1.666667e+00, 2.000000e+00 (4e+00), 3.000000e+00
Desc(wait_trongngay$cho_XN_ketthuc_XN)
## -------------------------------------------------------------------------
## wait_trongngay$cho_XN_ketthuc_XN (numeric)
##
## length n NAs unique
## 7e+02 7e+02 0 5e+02
## 100.0% 0.0%
##
## .05 .10 .25 median
## 3.66666667e-01 5.83333333e-01 1.61666667e+00 3.43333333e+00
##
## range sd vcoef mad
## 1.07000000e+01 2.53412339e+00 6.71376428e-01 2.94049000e+00
##
## 0s mean meanCI
## 0 3.77451946e+00 3.58793218e+00
## 0.0% 3.96110673e+00
##
## .75 .90 .95
## 5.71666667e+00 7.31666667e+00 8.28333333e+00
##
## IQR skew kurt
## 4.10000000e+00 4.22629954e-01 -8.11480922e-01
##
## lowest : 1.66666667e-02, 5.00000000e-02 (2e+00), 6.66666667e-02, 6.66666667e-02, 8.33333333e-02 (2e+00)
## highest: 9.80000000e+00, 9.86666667e+00, 1.00333333e+01, 1.02333333e+01, 1.07166667e+01
Desc(wait_trongngay$cho_XN_ketthuc_SA)
## -------------------------------------------------------------------------
## wait_trongngay$cho_XN_ketthuc_SA (numeric)
##
## length n NAs unique
## 7e+02 7e+02 0 5e+02
## 100.0% 0.0%
##
## .05 .10 .25 median
## 7.25000000e-01 1.13333333e+00 2.28333333e+00 4.08333333e+00
##
## range sd vcoef mad
## 1.07666667e+01 2.56349666e+00 5.85576574e-01 3.06404000e+00
##
## 0s mean meanCI
## 0 4.37773090e+00 4.18898087e+00
## 0.0% 4.56648092e+00
##
## .75 .90 .95
## 6.43333333e+00 7.91666667e+00 8.92500000e+00
##
## IQR skew kurt
## 4.15000000e+00 3.26486530e-01 -7.99498185e-01
##
## lowest : 1.66666667e-02, 3.33333333e-02, 8.33333333e-02, 1.16666667e-01, 1.50000000e-01
## highest: 1.04500000e+01, 1.05000000e+01, 1.05500000e+01, 1.07833333e+01, 1.07833333e+01
Th???i gian ch??? trung b??nh 8,4 gi??? (t???i thi???u 2,6 gi???, t???i ða 13,6 gi???
# ngay kham
wait_trongngay$ngay <- as.factor(wait_trongngay$ngay)
d = ggplot(wait_trongngay, aes(x=ngay, y= thoi_cho_gio ) ) +
geom_boxplot(aes(x=ngay , y = thoi_cho_gio , col=ngay ) , show.legend = FALSE ) +
theme_bw()+
geom_jitter(aes(col=ngay ), width = 0.4 , show.legend = FALSE) +
xlab("C\u00E1c ng\u00E0y trong th\u00E1ng 3") +
ylab("Th\u1EDDi gian ch\u1EDD trong ng\u00E0y (gi\u1EDD)") +
ggtitle("C\u00E1c ng\u00E0y trong th\u00E1ng 3") +
theme_economist()+
theme(
plot.title = element_text(color="red3", size=16, face="bold"),
axis.title.x = element_text(color="chocolate3", size=16, face="bold"),
axis.title.y = element_text(color="#993333", size=16, face="bold")
)+
stat_summary(fun.y=mean, colour='darkblue', geom="point", hape=18, size=1.5,show_guide = FALSE)+
stat_summary(fun.y=mean, colour= 'darkblue', geom="text", show_guide = FALSE,
vjust=1.5, aes( label=round(..y.., digits=1)))
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
## Warning: Ignoring unknown parameters: hape
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
d
m = ggplot(wait_trongngay, aes(x=thu, y= thoi_cho_gio ) ) +
geom_boxplot(aes(col=thu) , show.legend = FALSE ) +
theme_bw()+
geom_jitter(aes(col=thu ), width = 0.4 , show.legend = FALSE) +
xlab("Th\u1EE9 trong tu\u1EA7n ") +
ylab("Th\u1EDDi gian ch\u1EDD (gi\u1EDD)") +
ggtitle("Th\u1EDDi gian ch\u1EDD c\u1EE7a c\u00E1c ng\u00E0y trong m\u1ED7i tu\u1EA7n th\u00E1ng 3") +
theme_economist()+
theme(
plot.title = element_text(color="red3", size=16, face="bold"),
axis.title.x = element_text(color="chocolate3", size=16, face="bold"),
axis.title.y = element_text(color="#993333", size=16, face="bold")
)+
stat_summary(fun.y=mean, colour='darkblue', geom="point", hape=18, size=1.5,show_guide = FALSE)+
stat_summary(fun.y=mean, colour= 'darkblue', geom="text", show_guide = FALSE,
vjust=1.5, aes( label=round(..y.., digits=1)))
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
## Warning: Ignoring unknown parameters: hape
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
m
# dia chi
a = ggplot(wait_trongngay, aes(x=diachi, y= thoi_cho_gio ) ) +
geom_boxplot(aes(col=diachi) , show.legend = FALSE ) +
theme_bw()+
geom_jitter(aes(col=diachi ), width = 0.4 , show.legend = FALSE) +
xlab("\u0110\u1ECBa ch\u1EC9") +
ylab("Th\u1EDDi gian ch\u1EDD (gi\u1EDD)") +
ggtitle("Th\u1EDDi gian ch\u1EDD theo \u0110\u1ECBa ch\u1EC9") +
theme_economist()+
theme(
plot.title = element_text(color="red3", size=16, face="bold"),
axis.title.x = element_text(color="chocolate3", size=16, face="bold"),
axis.title.y = element_text(color="#993333", size=16, face="bold")
)+
stat_summary(fun.y=mean, colour='darkblue', geom="point", hape=18, size=1.5,show_guide = FALSE)+
stat_summary(fun.y=mean, colour= 'darkblue', geom="text", show_guide = FALSE,
vjust=1.5, aes( label=round(..y.., digits=1)))
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
## Warning: Ignoring unknown parameters: hape
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
a
names(wait_trongngay)
## [1] "ngayNV" "ngay" "thu"
## [4] "id" "stt" "diachi"
## [7] "loaikham" "Dky_tongdai" "t1_phatso"
## [10] "t2_nhanB" "t3_dongT" "t4_kham_sta"
## [13] "t5_CD_SA" "t6_SA_end" "t5b_CD_XN"
## [16] "t6b_tiepnhan_XN" "t7_traKQ_XN" "t8_kham_end"
## [19] "maxtg" "thoi_cho" "Trong_ngay"
## [22] "thoi_cho_gio" "nhom_t1" "cho_phatso"
## [25] "cho_nhanbenh" "cho_dongtien" "cho_kham_SA"
## [28] "cho_SA_end" "cho_kham_XN" "cho_XN_tiepnhan_CD"
## [31] "cho_XN_KQ_tiepnhan" "cho_XN_ketthuc_XN" "cho_XN_ketthuc_SA"
k = ggplot(wait_trongngay, aes(x=loaikham, y= thoi_cho_gio ) ) +
geom_boxplot(aes(col=loaikham) , show.legend = FALSE ) +
theme_bw()+
geom_jitter(aes(col=loaikham ), width = 0.4 , show.legend = FALSE) +
xlab("\u0110\u0103ng k\u00FD kh\u00E1m m\u1EDBi v\u00E0 c\u0169") +
ylab("Th\u1EDDi gian ch\u1EDD (gi\u1EDD)") +
ggtitle("Th\u1EDDi gian ch\u1EDD theo \u0110\u0103ng k\u00FD kh\u00E1m m\u1EDBi v\u00E0 c\u0169") +
theme_economist()+
theme(
plot.title = element_text(color="red3", size=16, face="bold"),
axis.title.x = element_text(color="chocolate3", size=16, face="bold"),
axis.title.y = element_text(color="#993333", size=16, face="bold")
)+
stat_summary(fun.y=mean, colour='darkblue', geom="point", hape=18, size=1.5,show_guide = FALSE)+
stat_summary(fun.y=mean, colour= 'darkblue', geom="text", show_guide = FALSE,
vjust=1.5, aes( label=round(..y.., digits=1)))
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
## Warning: Ignoring unknown parameters: hape
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
k
# Dang ky tong dai
names(wait_trongngay)
## [1] "ngayNV" "ngay" "thu"
## [4] "id" "stt" "diachi"
## [7] "loaikham" "Dky_tongdai" "t1_phatso"
## [10] "t2_nhanB" "t3_dongT" "t4_kham_sta"
## [13] "t5_CD_SA" "t6_SA_end" "t5b_CD_XN"
## [16] "t6b_tiepnhan_XN" "t7_traKQ_XN" "t8_kham_end"
## [19] "maxtg" "thoi_cho" "Trong_ngay"
## [22] "thoi_cho_gio" "nhom_t1" "cho_phatso"
## [25] "cho_nhanbenh" "cho_dongtien" "cho_kham_SA"
## [28] "cho_SA_end" "cho_kham_XN" "cho_XN_tiepnhan_CD"
## [31] "cho_XN_KQ_tiepnhan" "cho_XN_ketthuc_XN" "cho_XN_ketthuc_SA"
dk = ggplot(wait_trongngay, aes(x=Dky_tongdai, y= thoi_cho_gio ) ) +
geom_boxplot(aes(col=Dky_tongdai) , show.legend = FALSE ) +
theme_bw()+
geom_jitter(aes(col=Dky_tongdai ), width = 0.4 , show.legend = FALSE) +
xlab("\u0110\u0103ng k\u00FD kh\u00E1m qua t\u1ED5ng \u0111\u00E0i") +
ylab("Th\u1EDDi gian ch\u1EDD (gi\u1EDD)") +
ggtitle("Th\u1EDDi gian ch\u1EDD theo \u0110\u0103ng k\u00FD kh\u00E1m qua t\u1ED5ng \u0111\u00E0i") +
theme_economist()+
theme(
plot.title = element_text(color="red3", size=16, face="bold"),
axis.title.x = element_text(color="chocolate3", size=16, face="bold"),
axis.title.y = element_text(color="#993333", size=16, face="bold")
)+
stat_summary(fun.y=mean, colour='darkblue', geom="point", hape=18, size=1.5,show_guide = FALSE)+
stat_summary(fun.y=mean, colour= 'darkblue', geom="text", show_guide = FALSE,
vjust=1.5, aes( label=round(..y.., digits=1)))
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
## Warning: Ignoring unknown parameters: hape
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
dk
# cac moc thoi diem bat dau lay so
t1 = ggplot(wait_trongngay, aes(x=nhom_t1, y= thoi_cho_gio ) ) +
geom_boxplot(aes(col=nhom_t1) , show.legend = FALSE ) +
theme_bw()+
geom_jitter(aes(col=nhom_t1 ), width = 0.4 , show.legend = FALSE) +
xlab("Kho\u1EA3ng th\u1EDDi gian l\u1EA5y s\u1ED1") +
ylab("Th\u1EDDi gian ch\u1EDD (gi\u1EDD)") +
ggtitle("Th\u1EDDi gian ch\u1EDD theo Kho\u1EA3ng th\u1EDDi gian l\u1EA5y s\u1ED1") +
theme_economist()+
theme(
plot.title = element_text(color="red3", size=16, face="bold"),
axis.title.x = element_text(color="chocolate3", size=16, face="bold"),
axis.title.y = element_text(color="#993333", size=16, face="bold")
)+
stat_summary(fun.y=mean, colour='darkblue', geom="point", hape=18, size=1.5,show_guide = FALSE)+
stat_summary(fun.y=mean, colour= 'darkblue', geom="text", show_guide = FALSE,
vjust=1.5, aes( label=round(..y.., digits=1)))
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
## Warning: Ignoring unknown parameters: hape
## Warning: `show_guide` has been deprecated. Please use `show.legend`
## instead.
t1
Th???i gian ch??? trung b??nh c???a BN theo kho???ng th???i gian b???t ð???u l???y s???: cao nh???t trong kho???ng th???i gian t??? 5-6 gi??? ðãng k??
#################### thoi gian sieu am ############
long_SA <- gather(wait_trongngay, diadiem, thoigian, -c(1:8,15:17,19:33))
long_SA$diadiem <- as.factor(long_SA$diadiem)
######################### thoi gian cho qua cac thoi diem ##############################
stat_sum_single <- function(fun, geom="point", ...) {
stat_summary(fun.y=fun, colour="red", geom=geom, size = 3, ...)
}
stat_sum_df <- function(fun, geom="crossbar", ...) {
stat_summary(fun.data=fun, geom=geom, width=0.2, ...)
}
m1 <- ggplot(aes(x = diadiem , y = thoigian),data = long_SA) +
geom_line(aes(group = id), color = "gold3") +
theme_bw() + xlab("KHU V\u1EF0C \u0110O TH\u1EDCI GIAN") +
theme_economist()
m1 <- m1+
stat_sum_df("mean_cl_normal",geom="pointrange")+
stat_summary(fun.y="mean",geom="line") +
ylab("TH\u1EDCI \u0110I\u1EC2M \u0110O ") +
ggtitle("BI\u1EC2U \u0110\u1ED2 \u0110O TH\u1EDCI GIAN CH\u1EDC QUA C\u00C1C KH\u00C2U NH\u1EACN B\u1EC6NH" )
## Warning: Ignoring unknown parameters: width
m1
## geom_path: Each group consists of only one observation. Do you need to
## adjust the group aesthetic?
########################### thoi gian XET NGHIEM ##################################
long_xn <- gather(wait_trongngay, diadiem, thoigian, -c(1:8,13:14,19:33))
long_xn$diadiem <- as.factor(long_xn$diadiem)
######################### thoi gian cho qua cac thoi diem ########################
stat_sum_single <- function(fun, geom="point", ...) {
stat_summary(fun.y=fun, colour="red", geom=geom, size = 3, ...)
}
stat_sum_df <- function(fun, geom="crossbar", ...) {
stat_summary(fun.data=fun, geom=geom, width=0.2, ...)
}
m1 <- ggplot(aes(x = diadiem , y = thoigian),data = long_xn) +
geom_line(aes(group = id), color = "gold3") +
theme_bw() + xlab("KHU V\u1EF0C \u0110O TH\u1EDCI GIAN") +
theme_economist()
m1 <- m1+
stat_sum_df("mean_cl_normal",geom="pointrange")+
stat_summary(fun.y="mean",geom="line") +
ylab("TH\u1EDCI \u0110I\u1EC2M \u0110O ") +
ggtitle("BI\u1EC2U \u0110\u1ED2 \u0110O TH\u1EDCI GIAN CH\u1EDC QUA C\u00C1C KH\u00C2U NH\u1EACN B\u1EC6NH" )
## Warning: Ignoring unknown parameters: width
m1
## geom_path: Each group consists of only one observation. Do you need to
## adjust the group aesthetic?