library(tidyverse)
library(kableExtra)Exercise
Your task is to re-create the Quarto file that will produce this HTML file exactly.
First, make sure you load the following packages because you will need them to create the graphs and tables below.
Dataset
The dataset we will use in this section is decathlon.csv.
dec <- read_csv("decathlon.csv")Histogram of 100m Times
The histogram below shows that the performance in the 100m event is somewhat normally distributed.
ggplot(data = dec) +
geom_histogram(mapping = aes (x = e_100m)) +
ggtitle("Histogram of 100m Sprint Times") +
xlab("Times in seconds") +
ylab("")Scatterplot of Shot Put & Discus Results
As expected, the scatterplot below shows a reasonably strong positive correlation between athletes’ performance in the Shot Put and Discus events.
ggplot(data = dec) +
geom_point(mapping = aes(x = shot_put, y = discus)) +
ggtitle("Scatterplot of Shot Put & Discus Distances") +
xlab("Metres") +
ylab("Metres")Table of Number of Athletes
The following chunk creates a table called dec2 containing the number of athletes who completed in each competition.
dec2 <- dec %>%
group_by(competition) %>%
summarise('# Athletes' = n())
dec2# A tibble: 2 × 2
competition `# Athletes`
<chr> <int>
1 Decastar 13
2 OlympicG 28
Use kable() and kable_styling() to format the dec2 table so that it looks like the table below. Make sure you have the following:
- The table should not be the full width.
- Change the column headings and caption.
- Colour the first row to be darkblue with white text.
- The code for creating this table does not appear in the HTML file.
| competition | # Athletes |
|---|---|
| Decastar | 13 |
| OlympicG | 28 |
Other Random Things…
Add Image
First add a .png file.