library("readr")
library("ggplot2")
library("dplyr")
library("ggrepel")
#Imports the GOT dataset (source: www.imbd.com)
screentimes <- read_csv("GOT_screentimes_1.csv")
#Extract characters with the most screentime, bevause we want to lable them in ggplot
screentimes_high <- top_n(screentimes, 10, screentime) # top_n() shows highest 10Game of Thrones Characters
Abstract
The 10 longest screentimes for game of thrones episodes vary between 117.30 and 293.3.
Introduction
In our analysis of game of thrones dataset, we compare screentime and number of starred episodes for all characters. We then label all characters with a high screentime (top 10).
Inserting intext citation: (Abrahms et al. 2019)
Results
Using {#sec-results} will mark this section in the R document, when used “@”. Like this: Section 2
# the above code with label will mark this figure in the Quarto document as Figure 1.
# show data as a scatter plot: screentime vs. number of episodes watched
# and label characters with high screentime
ggplot(screentimes, aes(screentime, episodes)) +
geom_point() +
geom_text_repel(data = screentimes_high,aes(label = name),min.segment.length = 0)Warning: Removed 15 rows containing missing values or values outside the scale range
(`geom_point()`).
Figure 2 shows the coat of arms of house Baratheon. And the scatterplot is shown in Figure 1, see Section 2.
create subfigure:
Exercise 6
In Table 1 are the top 10 characters
library(tidyverse)── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ forcats 1.0.0 ✔ stringr 1.5.2
✔ lubridate 1.9.4 ✔ tibble 3.3.0
✔ purrr 1.1.0 ✔ tidyr 1.3.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(knitr)
screentimes_high |>
arrange(desc(screentime)) |>
select(name, screentime, episodes) |>
kable()| name | screentime | episodes |
|---|---|---|
| Tyrion Lannister | 293.30 | 54 |
| Jon Snow | 268.15 | 49 |
| Daenerys Targaryen | 221.30 | 49 |
| Cersei Lannister | 201.45 | 52 |
| Sansa Stark | 199.30 | 47 |
| Arya Stark | 189.15 | 47 |
| Jaime Lannister | 162.30 | 43 |
| Theon Greyjoy | 123.30 | 39 |
| Samwell Tarly | 121.45 | 37 |
| Jorah Mormont | 117.30 | 42 |
References
Abrahms, Briana, Elliott L Hazen, Ellen O Aikens, et al. 2019. “Memory and Resource Tracking Drive Blue Whale Migrations.” Proceedings of the National Academy of Sciences 116 (12): 5582–87.