-
Notifications
You must be signed in to change notification settings - Fork 0
/
cards.R
52 lines (43 loc) · 998 Bytes
/
cards.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
50
51
52
library(ggplot2)
library(dplyr)
theme_set(theme_bw(base_size=20))
par(ps=20)
N <- 26
dat <- (read.csv(input_files[[1]])
%>% mutate(
trial=as.factor(trial)
, contact_potential = I*S/N
)
)
dat2 <- (dat
%>% filter(R0==2)
)
sim2 <- sim(R0=2) %>% mutate(trial="1")
sim2x <- sim(R0=2.3) %>% mutate(trial="1")
shoot <- (
ggplot(dat2, aes(x=timestep, y=I, color=trial))
+ geom_line(lty=3)
+ theme(legend.position="none")
)
print(shoot)
print(shoot2 <- shoot + geom_line(data=sim2, size=1.6))
print(shoot2 + geom_line(data=sim2x, size=1.6))
library(plyr)
stepFrame <- function(f){
newf <- f[-nrow(f), ]
newf$Inext <- f$I[-1]
return(newf)
}
stepdat <- ddply(dat, . (R0, trial), stepFrame)
stepdat2 <- (stepdat
%>% filter(R0==2)
)
step <- (
ggplot(stepdat2, aes(x=contact_potential, y=Inext, color=trial))
+ geom_point()
+ theme(legend.position="none")
+ xlab("Infection potential (SI/N)")
)
print(step)
print(step2 <- step+geom_abline(slope=2))
print(step2+geom_abline(slope=2.2))