①被験者背景の一覧(被験者数、年齢、性別、SBP)
library(tableone)
tbl_1<- CreateTableOne(vars = c("age","sex","al_SBP"),strata = "allocation", factorVars = c("sex"), data = d2)
tbl_1
## Stratified by allocation
## 1 2 p test
## n 232 231
## age (mean (SD)) 69.22 (9.20) 69.72 (9.17) 0.559
## sex = 2 (%) 77 (33.2) 76 (32.9) 1.000
## al_SBP (mean (SD)) 128.72 (15.58) 127.83 (16.63) 0.553
②箱ひげ図(年齢とSBP)
年齢を2群に
g_box_1 <- ggplot(d2)+
aes(x=factor(allocation),y=age)+
geom_boxplot(fill="grey")+
theme_classic()+
labs(x="allocation",y="age")
g_box_1
SBPを2群に分ける
g_box_2 <- ggplot(d2)+
aes(x=factor(allocation),y=al_SBP)+
geom_boxplot(fill="grey")+
theme_classic()+
labs(x="allocation",y="SBP")
g_box_2
③散布図(年齢とSBP)
年齢とSBPの散布図
g_point_1 <- ggplot(data = d2, aes(x=age,y=al_SBP))+
geom_point()+
labs(x="age",y="SBP")
g_point_1
治療法1の散布図
d2 %>% filter(allocation == 1) ->dd1
g_point_2 <- ggplot(dd1)+
aes(x=age,y=al_SBP)+
geom_point()+
theme_classic()+
labs(x="age",y="SBP")
g_point_2
治療法2の散布図
d2 %>% filter(allocation == 2) ->dd2
g_point_3 <- ggplot(dd2)+
aes(x=age,y=al_SBP)+
geom_point()+
theme_classic()+
labs(x="age",y="SBP")
g_point_3
治療法ごとの散布図
g_point_4 <- ggplot(d2)+
aes(x=age,y=al_SBP,group=allocation,color=allocation)+
geom_point()+
theme_classic()+
labs(x="age",y="SBP")
g_point_4
注)黒が治療法1、青が治療法2である