# 
# install.packages("DescTools")
library(DescTools)
lister <- read.delim("http://myweb.uiowa.edu/pbreheny/data/lister.txt")
lister.table <- Rev(table(lister))
print(lister.table)


# 
lister_manual <- data.frame("Group" = c(rep("Control", 35), rep("Sterile", 40)), 
                      "Outcome" = c(rep("Survived", 19), rep("Died", 16), rep("Survived", 34), rep("Died", 6)))

tab <- table(lister_manual)
tab


# 
fisher.test(lister.table)


# echo=FALSE
Table<-matrix(data=c("a","b","c","d"),nrow=2,byrow=TRUE)
rownames(Table)<-c("Option 1","Option 2")
colnames(Table)<-c("Success","Failure")
print(Table, quote = FALSE)


# echo=FALSE
print(lister.table)
table2<-lister.table
table2[1:2,1:2]<-c("a","c","b","d")
print(table2)


# 
OR <- (34*16)/(19*6)

OR


# 
logOR <- log(OR) # the log function in R is the natural log

logOR


# 
SElogOR<-sqrt((1/19)+(1/6)+(1/16)+(1/34))

SElogOR


# 
logCI <- logOR + qnorm(c(.025,.975)) * SElogOR

logCI


# 
CI <- exp(logCI)

CI

