-
Notifications
You must be signed in to change notification settings - Fork 7
/
chapter4.R
49 lines (34 loc) · 1.35 KB
/
chapter4.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
setwd("C:\\Users\\user\\Dropbox\\KNOU_강의개편\\학부_바이오통계학\\R")
setwd("C:\\Users\\KNOU_stat\\Dropbox\\KNOU_강의개편\\학부_바이오통계학\\R")
####
#### Program 4-1
setwd("C:/Users/KNOU_stat/R_codes")
dat0<-read.csv("biostat_ex_data.csv")
library(dplyr)
dat1<-dat0 %>% mutate_at(vars(sex, Recur, stage, smoking, obesity, Recur_1y,
post.CA19.9.binary, post.CA19.9.3grp),
as.factor)
library(ggplot2)
ggplot(dat1) + geom_histogram(aes(x=weight), color="black", fill="skyblue",
breaks=seq(40, 100, 10))
#### Program 4-2
t.test(weight~sex, data=dat1)
#### Program 4-3
wilcox.test(weight~sex, data=dat1)
#### Program 4-4
ggplot(dat1) + geom_histogram(aes(x=CEA), color="black", fill="skyblue")
#### Program 4-5
ggplot(dat1) + geom_histogram(aes(x=log(CEA)), color="black", fill="skyblue")
#### Program 4-6
fit<-aov(log(CEA)~stage, data=dat1)
summary(fit)
oneway.test(log(CEA)~stage, data=dat1)
#### Program 4-7
kruskal.test(CEA~stage, data=dat1)
#### Program 4-8
ggplot(dat1) +
geom_histogram(aes(x=log(post.CEA) - log(CEA)), color="black", fill="skyblue")
#### Program 4-9
t.test(log(dat1$post.CEA), log(dat1$CEA), paired=TRUE)
#### Program 4-10
wilcox.test(log(dat1$post.CEA), log(dat1$CEA), paired=TRUE)