#install.packages("pacman")
library("pacman")
p_install("dplyr", force = FALSE)
p_install("ggplot2", force = FALSE)
p_install("readr", force = FALSE)
p_install("tidyr", force = FALSE)
p_install("ggrepel", force = FALSE)
library("readr")
library("ggplot2")
library("dplyr")
library("ggrepel")Game of Thrones Screentime
Here, we analyse the screentimes of all characters in the HBO TV Series Game of Thrones (a pretty goot really brutal series, btw).
Installing needed packages
Installing needed packages is missing, version control? How do we make sure, that the packages used are still working or available in a few years?
Import Data
# Good thing is, that relativ paths were used
screentimes <- read_csv("data/GOT_screentimes_1.csv")Rows: 191 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (4): name, imdb_url, portrayed_by_name, portrayed_by_imdb_url
dbl (2): screentime, episodes
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(screentimes)# A tibble: 6 × 6
name imdb_url screentime episodes portrayed_by_name portrayed_by_imdb_url
<chr> <chr> <dbl> <dbl> <chr> <chr>
1 Tyrion L… http://… 293. 54 Peter Dinklage http://www.imdb.com/…
2 Jon Snow http://… 268. 49 Kit Harington http://www.imdb.com/…
3 Daenerys… http://… 221. 49 Emilia Clarke http://www.imdb.com/…
4 Cersei L… http://… 201. 52 Lena Headey http://www.imdb.com/…
5 Sansa St… http://… 199. 47 Sophie Turner http://www.imdb.com/…
6 Arya Sta… http://… 189. 47 Maisie Williams http://www.imdb.com/…
Select certain actors
Select the 10 characters with the highest screentimes
# select the 10 characters with the highest screentimes
screentimes_high <- top_n(screentimes, 10, screentime) Plotting screentime vs. episodes
Create a scatterplot with screentime and number of episodes starring
# create a scatterplot with screentime and number of episodes starring
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()`).
# Warning: 15 rows containing missing values or values outside scale range