-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsteps.R
More file actions
41 lines (33 loc) · 683 Bytes
/
steps.R
File metadata and controls
41 lines (33 loc) · 683 Bytes
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
par (cex=1.5)
finTime <- 8
i0 <- 10
C <- 4
steps <- 2
mult <- 6
ss <- mult*steps
basePlot <- function(t, i){
plot(t, i
, type = "l"
, xlab = "Time (weeks)"
, ylab = "Weekly incidence"
)
}
arrowStep <- function(t, i, astart, adist, asteps, ss){
pts <- (astart + adist*(0:asteps)/asteps)*ss
x <- t[pts]
y <- i[pts]
points(c(min(x), max(x)), c(min(y), max(y)))
arrows(x[-length(x)], y[-length(y)]
, x[-1], y[-length(y)]
)
arrows(x[-1], y[-length(y)]
, x[-1], y[-1]
, length=0
)
}
t <- (0:(finTime*ss))/ss
i <- i0*exp(t/C)
basePlot(t, i)
arrowStep(t, i, astart=3, adist=4, asteps=3, ss)
basePlot(t, i)
arrowStep(t, i, astart=3, adist=4, asteps=2, ss)