#importa a biblioteca
library(tidyverse)
## ── Attaching packages ──────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.0 ✓ purrr 0.3.3
## ✓ tibble 2.1.3 ✓ dplyr 0.8.5
## ✓ tidyr 1.0.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ─────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(ggbeeswarm)
series = read_csv("data/series_from_imdb.csv.zip")
## Parsed with column specification:
## cols(
## series_name = col_character(),
## Episode = col_character(),
## series_ep = col_double(),
## season = col_double(),
## season_ep = col_double(),
## url = col_character(),
## UserRating = col_double(),
## UserVotes = col_double(),
## r1 = col_double(),
## r2 = col_double(),
## r3 = col_double(),
## r4 = col_double(),
## r5 = col_double(),
## r6 = col_double(),
## r7 = col_double(),
## r8 = col_double(),
## r9 = col_double(),
## r10 = col_double()
## )
# Nunca usar read.csv()
glimpse(series)
## Observations: 63,956
## Variables: 18
## $ series_name <chr> "Altered Carbon", "Altered Carbon", "Altered Carbon", "Al…
## $ Episode <chr> "Out of the Past", "Fallen Angel", "In a Lonely Place", "…
## $ series_ep <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9,…
## $ season <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ season_ep <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9,…
## $ url <chr> "http://www.imdb.com/title/tt5989942/?ref_=ttep_ep1", "ht…
## $ UserRating <dbl> 7.9, 7.9, 8.1, 8.6, 8.4, 8.4, 8.3, 8.3, 8.5, 8.5, 8.1, 8.…
## $ UserVotes <dbl> 3673, 2868, 2621, 2841, 2417, 2345, 2515, 2203, 2274, 249…
## $ r1 <dbl> 0.011979308, 0.011157601, 0.011064479, 0.011967617, 0.012…
## $ r2 <dbl> 0.004900626, 0.004184100, 0.003052270, 0.003167899, 0.003…
## $ r3 <dbl> 0.005445140, 0.004881450, 0.004959939, 0.003167899, 0.003…
## $ r4 <dbl> 0.013340594, 0.012552301, 0.009156810, 0.010207673, 0.007…
## $ r5 <dbl> 0.029403757, 0.029986053, 0.019458222, 0.018655403, 0.019…
## $ r6 <dbl> 0.07187585, 0.07147838, 0.06486074, 0.03871876, 0.0496483…
## $ r7 <dbl> 0.16662129, 0.18654114, 0.14650897, 0.08658923, 0.1092263…
## $ r8 <dbl> 0.3283420, 0.3518131, 0.3410912, 0.1964097, 0.2581713, 0.…
## $ r9 <dbl> 0.18812959, 0.15062762, 0.20030523, 0.30095037, 0.2767894…
## $ r10 <dbl> 0.1799619, 0.1767782, 0.1995422, 0.3301654, 0.2602400, 0.…
Filtrar os dados pelo nome da serie:
got = series %>%
filter(series_name == "Game of Thrones")
#View(got)
got %>%
ggplot(mapping = aes(x = "GoT", y = UserRating)) +
geom_point(alpha = 0.25)
got %>%
ggplot(mapping = aes(x = "GoT", y = UserRating)) +
geom_jitter(height = 0, width = .1, alpha = .4)
got %>%
ggplot(mapping = aes(x = "GoT", y = UserRating)) +
geom_quasirandom(width = .15)
library(ggbeeswarm)
got %>%
ggplot(mapping = aes(x = "GoT", y = UserVotes)) +
geom_quasirandom(width = .15, color = "red")
Por temporada:
got %>%
ggplot(mapping = aes(y = UserRating, x = season)) +
geom_quasirandom(width = .1, color = "black", alpha = .5)
got %>%
ggplot(mapping = aes(y = UserVotes, x = season)) +
geom_quasirandom(width = .1, color = "black", alpha = .6)
got %>%
ggplot(mapping = aes(y = UserRating, x = season_ep)) +
geom_quasirandom(width = .1, color = "blue", alpha = .6)
got %>%
ggplot(mapping = aes(y = UserRating, x = season_ep, group = season)) +
geom_line()
got %>%
ggplot(mapping = aes(y = UserRating, x = series_ep, group = season, color = season)) +
geom_line(alpha = 0.7) +
geom_point()