{"id":22966643,"url":"https://github.com/favstats/got_ratings","last_synced_at":"2026-02-14T15:32:30.949Z","repository":{"id":108350519,"uuid":"187913968","full_name":"favstats/got_ratings","owner":"favstats","description":"Game of Thrones Ratings","archived":false,"fork":false,"pushed_at":"2019-05-22T00:36:42.000Z","size":458,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-11T22:35:01.243Z","etag":null,"topics":["data-visualization","data-viz","game-of-thrones"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/favstats.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-21T21:09:34.000Z","updated_at":"2019-05-23T09:53:41.000Z","dependencies_parsed_at":"2023-05-18T15:20:33.505Z","dependency_job_id":null,"html_url":"https://github.com/favstats/got_ratings","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/favstats/got_ratings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fgot_ratings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fgot_ratings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fgot_ratings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fgot_ratings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/favstats","download_url":"https://codeload.github.com/favstats/got_ratings/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fgot_ratings/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29448001,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T14:10:32.461Z","status":"ssl_error","status_checked_at":"2026-02-14T14:09:49.945Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-visualization","data-viz","game-of-thrones"],"created_at":"2024-12-14T20:44:55.419Z","updated_at":"2026-02-14T15:32:30.934Z","avatar_url":"https://github.com/favstats.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"Game of Thrones Ratings\n================\nFabio Votta\n2019-05-22 02:34:35\n\n## Packages and Folders\n\n``` r\n# Install these packages if you don't have them yet\n# if (!require(\"pacman\")) install.packages(\"pacman\")\n# devtools::install_github(\"favstats/tidytemplate\")\n\npacman::p_load(tidyverse, tidytemplate, htmltab, \n               janitor, gameofthrones, extrafont, \n               scales, ggthemes)\n\n# Creates folders\n# tidytemplate::data_dir()\n# tidytemplate::images_dir()\n```\n\n## Scraping Views from Wikipedia\n\n``` r\ngot_tables \u003c- \"https://en.wikipedia.org/wiki/List_of_Game_of_Thrones_episodes\"\n\n\nepisode_list \u003c- 2:9 %\u003e% \n  map_dfr(~htmltab(got_tables, .x) %\u003e% mutate(season = .x - 1)) %\u003e% \n  clean_names() %\u003e% \n  mutate_at(vars(no_overall, no_inseason, u_s_viewers_millions), as.numeric) %\u003e% \n  mutate(season = str_glue(\"Season {season}\")) %\u003e% \n  mutate(written_by = ifelse(str_detect(written_by, \"David Benioff \u0026 D. B. Weiss\"), \"David Benioff \u0026 D. B. Weiss\", written_by))  %\u003e% \n  mutate(title = str_remove_all(title, '\\\\\"'))\n\n# ## save data after scraping\nsave(episode_list, file = \"data/episode_list.Rdata\")\n```\n\n## Views over time\n\n``` r\nepisode_list %\u003e% \n  ggplot(aes(no_overall, u_s_viewers_millions, fill = season)) +\n  geom_col(alpha = 0.9, position = position_dodge(width = 0.1)) +\n  ggthemes::theme_hc() +\n  scale_fill_got(\"\", discrete = T, option = \"Targaryen\") +\n  scale_x_continuous(breaks = seq(0, 70, 10)) +\n  labs(y = \"US Viewers in Millions\", \n       x = \"Episode Number\", \n       title = \"Game of Thrones\", \n       subtitle =  \"US viewers  per episode\", \n       caption = \"Source: Nielsen Media Research\") +\n  guides(fill = guide_legend(nrow = 1)) +\n  theme(plot.title = element_text(size = 20, face = \"bold\", hjust = 0.5, family = \"Game of Thrones\"),\n        plot.subtitle = element_text(size = 10, hjust = 0.5, family = \"Game of Thrones\"),\n        plot.caption = element_text(size = 8))\n```\n\n\u003cimg src=\"rating_scraper_files/figure-gfm/unnamed-chunk-4-1.png\" style=\"display: block; margin: auto;\" /\u003e\n\n``` r\nggsave_it(season_views, width = 9, height = 5)\n```\n\n## How many episodes were written by which writer?\n\n``` r\nepisode_list %\u003e% \n  count(written_by, sort = T)\n```\n\n    ## # A tibble: 5 x 2\n    ##   written_by                      n\n    ##   \u003cchr\u003e                       \u003cint\u003e\n    ## 1 David Benioff \u0026 D. B. Weiss    51\n    ## 2 Bryan Cogman                   11\n    ## 3 Dave Hill                       4\n    ## 4 George R. R. Martin             4\n    ## 5 Vanessa Taylor                  3\n\n## How many episodes were directed by which director?\n\n``` r\nepisode_list %\u003e% \n  count(directed_by, sort = T)\n```\n\n    ## # A tibble: 20 x 2\n    ##    directed_by                     n\n    ##    \u003cchr\u003e                       \u003cint\u003e\n    ##  1 David Nutter                    9\n    ##  2 Alan Taylor                     7\n    ##  3 Alex Graves                     6\n    ##  4 Jeremy Podeswa                  6\n    ##  5 Mark Mylod                      6\n    ##  6 Miguel Sapochnik                6\n    ##  7 Daniel Minahan                  5\n    ##  8 Alik Sakharov                   4\n    ##  9 Michelle MacLaren               4\n    ## 10 Brian Kirk                      3\n    ## 11 Daniel Sackheim                 2\n    ## 12 David Petrarca                  2\n    ## 13 Jack Bender                     2\n    ## 14 Matt Shakman                    2\n    ## 15 Michael Slovis                  2\n    ## 16 Neil Marshall                   2\n    ## 17 Tim Van Patten                  2\n    ## 18 D. B. Weiss                     1\n    ## 19 David Benioff                   1\n    ## 20 David Benioff \u0026 D. B. Weiss     1\n\n## Scraping Rotten Tomatoes Ratings\n\nCreating a function to get the ratings\n\n``` r\nget_rotten_ratings \u003c- function(link) {\n  \n  raw_html \u003c- read_html(link)\n  \n  rotten_rating \u003c- raw_html %\u003e% \n    html_nodes(\"#scoreStats div:nth-child(1)\") %\u003e% \n    html_text() %\u003e% \n    parse_number()\n  \n  rotten_score \u003c-  raw_html %\u003e% \n    html_nodes(\"#tomato_meter_link \u003e span.meter-value.superPageFontColor\") %\u003e% \n    html_text() %\u003e% \n    parse_number()\n    \n  final_data \u003c- tibble(rotten_rating, rotten_score)\n  \n  return(final_data)\n  \n}\n\n\nepisode_ratings \u003c- episode_list %\u003e% \n  mutate(season = str_replace(season, \"Season \", \"s0\")) %\u003e% \n  mutate(episode = ifelse(nchar(no_inseason) == 1, paste0(\"e0\", no_inseason), paste0(\"e\", no_inseason))) %\u003e% \n  mutate(rottenlink = str_glue(\"https://www.rottentomatoes.com/tv/game_of_thrones/{season}/{episode}\")) %\u003e% \n  pull(rottenlink) %\u003e% \n  map_dfr(get_rotten_ratings) %\u003e% \n  bind_cols(episode_list, .) \n\n# ## save data after scraping\nsave(episode_ratings, file = \"data/episode_ratings.Rdata\")\n```\n\n## Ratings by Writer\n\n``` r\nepisode_ratings %\u003e% \n  mutate(written_by = fct_reorder(written_by, rotten_rating)) %\u003e% \n  ggplot(aes(written_by, rotten_rating)) +\n  geom_jitter(width = 0.3) +\n  geom_violin(alpha = 0.75, aes(fill = written_by)) +\n  geom_boxplot(width = 0.05) +\n  guides(fill = F) +\n  ggthemes::theme_hc() +\n  scale_fill_got(\"\", discrete = T, option = \"Margaery\") +\n  labs(y = \"Rotten Tomatoes Rating\", x = \"\", title = \"Game of Thrones\", subtitle = \"Ratings  by Writer\")  +\n  theme(plot.title = element_text(size = 20, face = \"bold\", hjust = 0.5, family = \"Game of Thrones\"),\n        plot.subtitle = element_text(size = 10, hjust = 0.5, family = \"Game of Thrones\"))\n```\n\n\u003cimg src=\"rating_scraper_files/figure-gfm/analysis-1.png\" style=\"display: block; margin: auto;\" /\u003e\n\n``` r\nggsave_it(writer_ratings, width = 9, height = 5)\n```\n\n## Scores by Writer\n\n``` r\nepisode_ratings %\u003e% \n  mutate(written_by = fct_reorder(written_by, rotten_score)) %\u003e% \n  ggplot(aes(written_by, rotten_score)) +\n  geom_jitter(width = 0.3) +\n  geom_violin(alpha = 0.75, aes(fill = written_by)) +\n  geom_boxplot(width = 0.05) +\n  guides(fill = F) +\n  ggthemes::theme_hc() +\n  scale_fill_got(\"\", discrete = T, option = \"Margaery\") +\n  labs(y = \"Rotten Tomatoes Scores\", x = \"\", title = \"Game of Thrones\", subtitle = \"Episode  Scores  by Writer\")  +\n  theme(plot.title = element_text(size = 20, face = \"bold\", hjust = 0.5, family = \"Game of Thrones\"),\n        plot.subtitle = element_text(size = 10, hjust = 0.5, family = \"Game of Thrones\"))\n```\n\n\u003cimg src=\"rating_scraper_files/figure-gfm/unnamed-chunk-9-1.png\" style=\"display: block; margin: auto;\" /\u003e\n\n``` r\nggsave_it(writer_scores, width = 9, height = 5)\n```\n\n## Rating by Director\n\n``` r\nepisode_ratings %\u003e% \n  mutate(directed_by = fct_reorder(directed_by, rotten_rating)) %\u003e% \n  ggplot(aes(directed_by, rotten_rating)) +\n  geom_jitter(width = 0.3) +\n  geom_violin(alpha = 0.75, aes(fill = directed_by)) +\n  geom_boxplot(width = 0.05) +\n  guides(fill = F) +\n  ggthemes::theme_hc() +\n  scale_fill_got(\"\", discrete = T, option = \"Stark2\") +\n  labs(y = \"Rotten Tomatoes Rating\", x = \"\", title = \"Game of Thrones\", subtitle = \"Ratings  by Director\")  +\n  theme(plot.title = element_text(size = 20, face = \"bold\", hjust = 0.5, family = \"Game of Thrones\"),\n        plot.subtitle = element_text(size = 10, hjust = 0.5, family = \"Game of Thrones\")) +\n  coord_flip()\n```\n\n\u003cimg src=\"rating_scraper_files/figure-gfm/unnamed-chunk-10-1.png\" style=\"display: block; margin: auto;\" /\u003e\n\n``` r\nggsave_it(director_ratings, width = 6, height = 12)\n```\n\n## Scores by Director\n\n``` r\nepisode_ratings %\u003e% \n  mutate(directed_by = fct_reorder(directed_by, rotten_score)) %\u003e% \n  ggplot(aes(directed_by, rotten_score)) +\n  geom_jitter(width = 0.3) +\n  geom_violin(alpha = 0.75, aes(fill = directed_by)) +\n  geom_boxplot(width = 0.05) +\n  guides(fill = F) +\n  ggthemes::theme_hc() +\n  scale_fill_got(\"\", discrete = T, option = \"Stark2\") +\n  labs(y = \"Rotten Tomatoes Rating\", x = \"\", title = \"Game of Thrones\", subtitle = \"Scores  by Director\")  +\n  theme(plot.title = element_text(size = 20, face = \"bold\", hjust = 0.5, family = \"Game of Thrones\"),\n        plot.subtitle = element_text(size = 10, hjust = 0.5, family = \"Game of Thrones\")) +\n  coord_flip()\n```\n\n\u003cimg src=\"rating_scraper_files/figure-gfm/unnamed-chunk-11-1.png\" style=\"display: block; margin: auto;\" /\u003e\n\n``` r\nggsave_it(director_scores, width = 6, height = 12)\n```\n\n## Rating by Episode\n\n``` r\nepisode_titles \u003c- episode_ratings %\u003e%\n  filter(rotten_rating \u003e 9.4 | rotten_rating \u003c 7.5) %\u003e% \n  filter(title != \"The Lion and the Rose\") %\u003e% \n  filter(title != \"The Bells\")\n\nepisode_ratings %\u003e% \n  ggplot(aes(no_overall, rotten_rating, color = season)) +\n  geom_point() +\n  geom_line(alpha = 0.75) +\n  ggrepel::geom_text_repel(data = episode_titles, aes(label = title), \n                           size = 2.5, nudge_y = 0.15, nudge_x = 3, seed = 200, color = \"black\") + \n  facet_wrap(~season, scales = \"free_x\", nrow = 1)  +\n  ggthemes::theme_hc() +\n  scale_color_got(\"\", discrete = T, option = \"Targaryen2\") +\n  labs(y = \"Rotten Tomatoes Rating\", x = \"\", title = \"Game of Thrones\", subtitle = \"Ratings  by Episode\")  +\n  theme(plot.title = element_text(size = 20, face = \"bold\", hjust = 0.5, family = \"Game of Thrones\"),\n        plot.subtitle = element_text(size = 10, hjust = 0.5, family = \"Game of Thrones\")) +\n  guides(color = F)  +\n  theme(axis.text.x = element_blank(),\n        axis.ticks.x = element_blank())\n```\n\n\u003cimg src=\"rating_scraper_files/figure-gfm/unnamed-chunk-12-1.png\" style=\"display: block; margin: auto;\" /\u003e\n\n``` r\nggsave_it(episode_ratings, width = 12, height = 6)\n```\n\n## Score by Episode\n\n``` r\nepisode_titles \u003c- episode_ratings %\u003e%\n  filter(rotten_score \u003c 80) %\u003e%\n  filter(title != \"The Lion and the Rose\") %\u003e%\n  filter(title != \"The Bells\")\n\nepisode_ratings %\u003e% \n  ggplot(aes(no_overall, rotten_score, color = season)) +\n  geom_point() +\n  geom_line(alpha = 0.75) +\n  ggrepel::geom_text_repel(data = episode_titles, aes(label = title),\n                           size = 2.5, nudge_y = 2, nudge_x = 5, seed = 200, color = \"black\") +\n  facet_wrap(~season, scales = \"free_x\", nrow = 1)  +\n  ggthemes::theme_hc() +\n  scale_color_got(\"\", discrete = T, option = \"Greyjoy\") +\n  labs(y = \"Rotten Tomatoes Score\", x = \"\", title = \"Game of Thrones\", subtitle = \"Scores  by Episode\")  +\n  theme(plot.title = element_text(size = 20, face = \"bold\", hjust = 0.5, family = \"Game of Thrones\"),\n        plot.subtitle = element_text(size = 10, hjust = 0.5, family = \"Game of Thrones\")) +\n  guides(color = F)  +\n  theme(axis.text.x = element_blank(),\n        axis.ticks.x = element_blank())\n```\n\n\u003cimg src=\"rating_scraper_files/figure-gfm/unnamed-chunk-13-1.png\" style=\"display: block; margin: auto;\" /\u003e\n\n``` r\nggsave_it(rotten_score, width = 12, height = 6)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavstats%2Fgot_ratings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffavstats%2Fgot_ratings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavstats%2Fgot_ratings/lists"}