```{r}
#Table 1
#Generate a summary table displaying population characteristics
```1 Objectives 🎯
- You are tasked with generating a simple analytically reproducible report on a fictitious outbreak.
- Download the files
df1.RDataandexercise3.qmdusing the links provided on the right-hand side of this page. For simplicity, please put these two files under the same folder and open the Quarto notebook in RStudio. - Complete each of the following tasks and render the document after each task or set of tasks to track your progress.
- The final output should be a Microsoft (MS) Word report named
exercise3.docx, containing all required tables, figures and corresponding captions.
2 Setup basic elements of the Quarto notebook
Tip
- See Quarto documentation about MS Word options
- See Quarto documentation about execution options
3 Create publication-ready summary statistics tables
Table 1
Table 2
```{r}
#Table 2
#Generate a summary table comparing the demographic characteristics of individuals who died versus those who are still alive
```
Tip
- See
gtsummarydocumentation for creating formatted summary tables - See
tbl-capoption to add a caption to a table generated by an executable code chunk
Other R packages for working with and customising tables include flextable and gt
Important
- Table captions currently do not display correctly when rendering a Quarto document to Word due to a known bug. However, captions render properly when exporting to HTML or PDF (simply change the output format in your Quarto document to see them appear as expected). This issue is expected to be resolved in future updates. In the next exercise, we will explore how to use captions alongside cross-references, as in this case captions are displayed correctly in rendered Quarto documents.
4 Create publication-ready figures
Figure 1
```{r}
#Figure 1
#Aggregate the data to get the weekly count of all cases, confirmed cases and deaths
weekly_data <- subdf |>
dplyr::group_by(week) |>
dplyr::summarise(count = dplyr::n(),
confirmed_count = sum(confirmed == "1"),
death_count = sum(death == "1"))
#Plot the weekly count of all cases, confirmed cases and deaths
weekly_data |>
ggplot2::ggplot(ggplot2::aes(x = week)) +
ggplot2::geom_line(ggplot2::aes(y = count,
color = "All cases"),
size = 1) +
ggplot2::geom_line(ggplot2::aes(y = confirmed_count,
color = "Confirmed cases"),
size = 1) +
ggplot2::geom_line(ggplot2::aes(y = death_count,
color = "Confirmed deaths"),
size = 1) +
ggplot2::labs(title = "Weekly count of all cases, confirmed cases and deaths",
x = "Week",
y = "Count",
color = "Legend")
```
Tip
- see
fig-capoption to add a caption to a figure generated by an executable code chunk;
5 Present statistical models and results
```{r}
#Logistic regression model
```Table 3
```{r}
#Table 3
```
Tip
- See
gtsummarydocumentation for creating formatted tables of regression model results
Ready to take it further? Once you have completed this exercise, you can add dynamic elements to your report ⭐⭐.
Reuse
CC-BY