> # Import Data -------------------------------------------------------------
> Covid <- read.csv("~/Residency/PMR Specific/Research/COVID and Dysphagia/Data\_Analytics/data/Adapted Data/Covid\_Dysphagia\_Adapted\_Data.csv")
> 
> # Library -----------------------------------------------------------------
> library(data.table);library(readr)
data.table 1.14.6 using 10 threads (see ?getDTthreads). Latest news: r-datatable.com
> library(haven);library(stringr)
> library(epitools);library(multcomp)
Loading required package: mvtnorm
Loading required package: survival

Attaching package: ‘survival’

The following object is masked from ‘package:epitools’:

 ratetable

Loading required package: TH.data
Loading required package: MASS

Attaching package: ‘TH.data’

The following object is masked from ‘package:MASS’:

 geyser

> library(dplyr); library(DataCombine)

Attaching package: ‘dplyr’

The following object is masked from ‘package:MASS’:

 select

The following objects are masked from ‘package:data.table’:

 between, first, last

The following objects are masked from ‘package:stats’:

 filter, lag

The following objects are masked from ‘package:base’:

 intersect, setdiff, setequal, union
Attaching package: ‘DataCombine’

The following object is masked from ‘package:data.table’:

 shift

> library(berryFunctions);library(ggplot2)

Attaching package: ‘berryFunctions’

The following object is masked from ‘package:dplyr’:

 between

The following object is masked from ‘package:data.table’:

 between

> 
> #Dysphagia and no dysphagia groups
> Dysphagia <- subset(Covid, DysphagiaYN==1)
> NoDysphagia <- subset(Covid, DysphagiaYN==0)
> 
> #Mark
> Covid$Mark <- 1
> 
> # Intro Descriptive Analysis ----------------------------------------------
> length(unique(Covid$ID)) #No repeats or redmissions
[1] 346
> 
> #Age
> summary(Covid$Age, na.rm = TRUE); sd(Covid$Age, na.rm = TRUE)
 Min. 1st Qu. Median Mean 3rd Qu. Max. NA's 
 20.00 55.00 65.00 63.86 74.00 97.00 2 
[1] 13.71073
> summary(NoDysphagia$Age, na.rm = TRUE); sd(NoDysphagia$Age, na.rm = TRUE)
 Min. 1st Qu. Median Mean 3rd Qu. Max. NA's 
 20.00 54.00 64.00 63.10 73.75 96.00 2 
[1] 13.87471
> summary(Dysphagia$Age, na.rm = TRUE); sd(Dysphagia$Age, na.rm = TRUE)
 Min. 1st Qu. Median Mean 3rd Qu. Max. 
 23.00 56.25 67.00 65.07 75.50 97.00 
[1] 13.4126
> 
> #Sex
> mean(Covid$Sex, na.rm = TRUE)\*100
[1] 66.56977
> 1-mean(Covid$Sex, na.rm = TRUE)\*100
[1] -65.56977
> mean(NoDysphagia$Sex, na.rm = TRUE)\*100
[1] 67.61905
> 1-mean(NoDysphagia$Sex, na.rm = TRUE)\*100
[1] -66.61905
> mean(Dysphagia$Sex, na.rm = TRUE)\*100
[1] 64.92537
> 1-mean(Dysphagia$Sex, na.rm = TRUE)\*100
[1] -63.92537
> 
> #Prevelance of dysphagia
> mean(Dysphagia$DysphagiaYN, na.rm = TRUE)
[1] 1
> mean(NoDysphagia$DysphagiaYN, na.rm = TRUE)
[1] 0
> 
> #Length of stay
> mean(Dysphagia$AC\_LOS, na.rm = TRUE)
[1] 31.23214
> mean(NoDysphagia$AC\_LOS, na.rm = TRUE)
[1] 20.26667
> 
> #Dysphagia at DC, resolution
> mean(Dysphagia$DysphagiaDCYN, na.rm = TRUE)
[1] 0.4029851
> mean(NoDysphagia$DysphagiaDCYN, na.rm = TRUE)
[1] 0.1037736
> 
> #Intubation
> mean(Dysphagia$O2\_AC\_IntubYN, na.rm = TRUE)
[1] 0.7846154
> mean(NoDysphagia$O2\_AC\_IntubYN, na.rm = TRUE)
[1] 0.5698925
> 
> #BMI
> mean(Dysphagia$BMI, na.rm = TRUE)
[1] 29.91071
> mean(NoDysphagia$BMI, na.rm = TRUE)
[1] 32.2
> 
> # Table 1 - Intubation -----------------------------------------------------------------
> #Cont/Binary/Categorical
> a <- list("Age","BMI"); b <- list("Sex","HTN","DM","HLD","CAD","CKD","CA","Alcohol")
> c <- list("Race","Smoker")
> 
> #Cont
> d <- aggregate(Covid[,c(unlist(a))], list(Covid$DysphagiaYN), mean, na.rm=TRUE); d <- round(d,1)
> e <- aggregate(Covid[,c(unlist(a))], list(Covid$DysphagiaYN), sd, na.rm=TRUE); e <- round(e,1)
> f <- cbind(data.frame(unlist(a)), paste(d[1,2:3],"±",e[1,2:3],sep=""),paste(d[2,2:3],"±",e[2,2:3],sep=""))
> colnames(f)= c("Variable","No\_Dysphagia","Dysphagia")
> 
> #All
> d <- aggregate(Covid[,c(unlist(a))], list(Covid$Mark), mean, na.rm=TRUE); d <- round(d,1)
> e <- aggregate(Covid[,c(unlist(a))], list(Covid$Mark), sd, na.rm=TRUE); e <- round(e,1)
> f <- cbind(f,paste(d[1,2],"±",e[1,2],sep=""))
> colnames(f)= c("Variable","No\_Dysphagia","Dysphagia","All")
> 
> #Binary
> d <- aggregate(Covid[,c(unlist(b))], list(Covid$DysphagiaYN), mean, na.rm=TRUE)
> d <- rbind(d, aggregate(Covid[,c(unlist(b))], list(Covid$Mark), mean, na.rm=TRUE)); d <- d[,-1]\*100; d <- round(d,1)
> d <- data.frame(rownames(t(d)),t(d)); colnames(d)=colnames(f); f <- rbind(f, d)
> 
> #Categorical
> #No Dysphagia
> Work <- NoDysphagia; Work$Race <- replace(Work$Race, is.na(Work$Race), 0)
> for (i in 1:length(c)){
+ d <- round(data.frame(Work %>% count(Work[,unlist(c[i])], Work[,unlist(c[i])]))[-1]/length(subset(Work[,unlist(c[i])], !is.na(Work[,unlist(c[i])])))\*100, 1)
+ d <- data.frame(paste(rep(unlist(c[i]),length(levels(as.factor(Work[,unlist(c[i])])))), levels(as.factor(Work[,unlist(c[i])])), sep=""),d[,1])
+ ifelse(exists("g"),g <- rbind(g,d),g <- d)
+ }
Error in data.frame(paste(rep(unlist(c[i]), length(levels(as.factor(Work[, : 
 arguments imply differing number of rows: 3, 4
> # 데이터 가져오기 -------------------------------------------------------------> Covid <- read.csv("~/Residency/PMR Specific/Research/COVID 및 연하곤란/데이터\_분석/데이터/적응 데이터/Covid\_연하곤란\_적응\_데이터.csv")> > # 라이브러리 -----------------------------------------------------------------> library(data.table);library(readr)10개의 스레드를 사용하는 data.table 1.14.6(?.getDTthreads 참조). 최신 뉴스: r-datatable.com> library(haven);library(stringr)> library(epitools);library(multcomp)필요한 패키지 로드 중: mvtnorm필요한 패키지 로드 중: 생존패키지 첨부: 'survival'다음 객체는 'package:epitools'에서 마스킹됩니다: ratetable필수 패키지를 로드 중입니다: TH.data필수 패키지 로드 중입니다: MASS패키지 첨부: 'TH.data'다음 오브젝트는 'package:MASS'에서 마스킹됩니다: geyser> library(dplyr); library(DataCombine)첨부 패키지: 'dplyr''package:MASS'에서 다음 개체를 마스킹합니다: select'package:data.table'에서 다음 개체가 마스크됩니다: between, first, last'package:stats'에서 다음 객체가 마스킹됩니다: filter, lag다음 객체는 'package:base'에서 마스크됩니다: intersect, setdiff, setequal, union첨부 패키지: 'DataCombine'다음 객체는 'package:data.table'에서 마스킹됩니다: shift> library(berryFunctions);library(ggplot2)첨부 패키지: 'berryFunctions'다음 객체는 'package:dplyr'에서 마스크됩니다: between다음 개체는 'package:data.table'에서 마스크됩니다: between> #연하장애 및 연하장애 없음 그룹> 연하곤란 <- 하위 집합(Covid, 연하곤란YN==1)> NoDysphagia <- subset(Covid, DysphagiaYN==0)> > #Mark> Covid$Mark <- 1> > # 소개 설명 분석 ----------------------------------------------> length(unique(Covid$ID)) #반복 또는 재전송 없음[1] 346> > #Age> summary(Covid$Age, na.rm = TRUE); sd(Covid$Age, na.rm = TRUE) Min. 1st Qu. 중앙값 평균 3rd Qu. Max. NA's  20.00 55.00 65.00 63.86 74.00 97.00 2 [1] 13.71073> summary(NoDysphagia$Age, na.rm = TRUE); sd(NoDysphagia$Age, na.rm = TRUE) Min. 1st Qu. 중앙값 평균 3rd Qu. Max. NA's  20.00 54.00 64.00 63.10 73.75 96.00 2 [1] 13.87471> summary(Dysphagia$Age, na.rm = TRUE); sd(Dysphagia$Age, na.rm = TRUE) Min. 1st Qu. 중앙값 평균 3rd Qu. Max.  23.00 56.25 67.00 65.07 75.50 97.00 [1] 13.4126> > #Sex> 평균(Covid$Sex, na.rm = TRUE)\*100[1] 66.56977> 1-mean(Covid$Sex, na.rm = TRUE)\*100[1] -65.56977> mean(NoDysphagia$Sex, na.rm = TRUE)\*100[1] 67.619051-평균(NoDysphagia$Sex, na.rm = TRUE)\*100 [1] > 1[1] -66.61905> 평균(연하장애$성, na.rm = TRUE)\*100[1] 64.925371-평균(연하장애$성별, na.rm = TRUE)\*100 [1] > 1[1] -63.92537> > #연하 장애 유병률> 평균(연하장애$연하장애YN, na.rm = TRUE)[1] 1> 평균(연하곤란$연하곤란YN, na.rm = TRUE)[1] 0> > #재원 기간> mean(Dysphagia$AC\_LOS, na.rm = TRUE)[1] 31.23214> 평균(NoDysphagia$AC\_LOS, na.rm = TRUE)[1] 20.26667> > DC에서 #연하 장애, 해상도> 평균(Dysphagia$DysphagiaDCYN, na.rm = TRUE)[1] 0.4029851평균(연하곤란$연하곤란DCYN, na.rm = TRUE) > 0.4029851[1] 0.1037736> > #삽관> mean(Dysphagia$O2\_AC\_IntubYN, na.rm = TRUE)[1] 0.7846154> mean(NoDysphagia$O2\_AC\_IntubYN, na.rm = TRUE)[1] 0.5698925> > #BMI> 평균(Dysphagia$BMI, na.rm = TRUE)[1] 29.91071> mean(NoDysphagia$BMI, na.rm = TRUE)[1] 32.2> > 표 1 - 삽관 -----------------------------------------------------------------#Cont/Binary/Categorical> a <- list("Age","BMI"); b <- list("Sex","HTN","DM","HLD","CAD","CKD","CA","Alcohol")> c <- list("Race","Smoker")> > #Cont> d <- aggregate(Covid[,c(unlist(a))], list(Covid$DysphagiaYN), mean, na.rm=TRUE); d <- round(d,1)> e <- aggregate(Covid[,c(unlist(a))], list(Covid$DysphagiaYN), sd, na.rm=TRUE); e <- round(e,1)> f <- cbind(data.frame(unlist(a)), paste(d[1,2:3],"±",e[1,2:3],sep=""),paste(d[2,2:3],"±",e[2,2:3],sep=""))> colnames(f)= c("Variable","No\_Dysphagia","Dysphagia")> > #All> d <- aggregate(Covid[,c(unlist(a))], list(Covid$Mark), mean, na.rm=TRUE); d <- round(d,1)> e <- aggregate(Covid[,c(unlist(a))], list(Covid$Mark), sd, na.rm=TRUE); e <- round(e,1)> f <- cbind(f,paste(d[1,2],"±",e[1,2],sep=""))> colnames(f)= c("Variable","No\_Dysphagia","Dysphagia","All")> > #Binary> d <- aggregate(Covid[,c(unlist(b))], list(Covid$DysphagiaYN), mean, na.rm=TRUE)> d <- rbind(d, aggregate(Covid[,c(unlist(b))], list(Covid$Mark), mean, na.rm=TRUE)); d <- d[,-1]\*100; d <- round(d,1)> d <- data.frame(rownames(t(d)),t(d)); colnames(d)=colnames(f); f <- rbind(f, d)> > #Categorical> #연하장애 없음> Work <- NoDysphagia; Work$Race <- replace(Work$Race, is.na(Work$Race), 0)> for (i in 1:length(c)){{+ d <- round(data.frame(Work %>% count(Work[,unlist(c[i])], Work[,unlist(c[i])])[-1]/length(subset(Work[,unlist(c[i])], !is.na(Work[,unlist(c[i)])))\*100, 1)+ d <- data.frame(paste(rep(unlist(c[i]),length(levels(as.factor(Work[,unlist(c[i])])))), levels(as.factor(Work[,unlist(c[i))])), sep=""),d[,1])+ ifelse(exis