1「生物統計学II第2回20231005_sampledata.xlsx」を用いて,以下の①〜③2における群の比較を行い,R Markdownで簡潔に結果を報告せよ.ただし,Sitagliptin群(allocation=1)とConventional群(allocation=2)とする

#library、データの読み込み

pacman::p_load(tidyverse,readxl,ggplot2,tidyverse,dplyr,tableone,ggpubr,ggrepel)
ds_allocation<-read_excel("/Users/abekohei/Downloads/PROLOGUE_raw data for submission 20160506.xlsx",sheet=2)

①被験者背景(被験者数(n),年齢,性別,SBP)の一覧表

tmp01 <- CreateTableOne(vars=c("age", "sex", "al_SBP"),
                        strata="allocation", 
                        factorVars=c("sex"), 
                        data=ds_allocation)
tmp01
##                     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
summary(ds_allocation)
##       ID             DM_treatment       Statin            age       
##  Length:463         Min.   :1.000   Min.   :0.0000   Min.   :38.00  
##  Class :character   1st Qu.:1.000   1st Qu.:0.0000   1st Qu.:64.00  
##  Mode  :character   Median :2.000   Median :1.0000   Median :70.00  
##                     Mean   :1.629   Mean   :0.7408   Mean   :69.47  
##                     3rd Qu.:2.000   3rd Qu.:1.0000   3rd Qu.:76.00  
##                     Max.   :2.000   Max.   :1.0000   Max.   :91.00  
##       sex           al_SBP      al_HbA1c(JDS)   al_max_IMT    
##  Min.   :1.00   Min.   : 80.0   Min.   :5.80    Min.   : 0.000  
##  1st Qu.:1.00   1st Qu.:118.5   1st Qu.:6.20    1st Qu.: 0.940  
##  Median :1.00   Median :128.0   Median :6.40    Median : 1.240  
##  Mean   :1.33   Mean   :128.3   Mean   :6.57    Mean   : 1.547  
##  3rd Qu.:2.00   3rd Qu.:138.0   3rd Qu.:6.80    3rd Qu.: 1.810  
##  Max.   :2.00   Max.   :190.0   Max.   :8.90    Max.   :12.900  
##    allocation   
##  Min.   :1.000  
##  1st Qu.:1.000  
##  Median :1.000  
##  Mean   :1.499  
##  3rd Qu.:2.000  
##  Max.   :2.000

②箱ひげ図(年齢,SBP)

#Sitagliptin群(allocation=1)とConventional群(allocation=2)と年齢
ggplot(ds_allocation,aes(x=factor(allocation),y=age))+
  geom_boxplot()+
  labs(title="Age_plot",x="allocation",y="age")

#Sitagliptin群(allocation=1)とConventional群(allocation=2)とSBP
ggplot(ds_allocation,aes(x=factor(allocation),y=al_SBP))+
  geom_boxplot()+
  labs(title="SBP_plot",x="allocation",y="al_SBP")

③散布図(年齢とSBP)

ggplot(ds_allocation,aes(x=age,y=al_SBP,color=factor(allocation)))+
geom_point()

allocation1:Sitagliptin

allocation2:Conventional