Skip to content

Commit c504df5

Browse files
committed
update sol
1 parent 853e371 commit c504df5

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

instructors/fig/03-challenge-instructor.R

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,10 @@ sim_multiple_chains <- epichains::simulate_chains(
4444
generation_time = function(x) generate(x = ebola_serialinter, times = x)
4545
)
4646

47-
# visualize ----------------------------------------
47+
# summarise ----------------------------------------
48+
49+
summary(sim_multiple_chains)
4850

49-
sim_chains_aggregate <-
50-
sim_multiple_chains %>%
51-
# use data.frame output from <epichains> object
52-
as_tibble() %>%
53-
# Count the daily number of cases in each chain
54-
mutate(day = ceiling(time)) %>%
55-
count(chain, day, name = "cases") %>%
56-
# Calculate the cumulative number of cases for each chain
57-
group_by(chain) %>%
58-
mutate(cumulative_cases = cumsum(cases)) %>%
59-
ungroup()
51+
# visualize ----------------------------------------
6052

61-
sim_chains_aggregate %>%
62-
# Create grouped chain trajectories
63-
ggplot(aes(x = day, y = cumulative_cases, group = chain)) +
64-
geom_line() +
65-
# Define a 100-case threshold
66-
geom_hline(aes(yintercept = 100), lty = 2) +
67-
ylim(0,100) +
68-
xlim(0,100) +
69-
labs(x = "Day", y = "Cumulative cases")
53+
# optional - not to assess

0 commit comments

Comments
 (0)