2024 Oct 31

top 10 highly rated movies with titles containing the word 'monster'

Code

load packages, read data

library(tidyverse)
library(gt)
monster_movie_genres <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2024/2024-10-29/monster_movie_genres.csv')
monster_movies <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2024/2024-10-29/monster_movies.csv')

filter, arrange, select, rename, slice

monster_movies_table <- monster_movies |> 
  filter(num_votes > 10000) |>
  arrange(desc(average_rating)) |> 
  filter(title_type == "movie") |> 
  select(primary_title, average_rating, num_votes) |>
  rename(title = primary_title, rating = average_rating, votes = num_votes) |> 
  slice(1:10) 

create gt table, format number, table styling

gt(monster_movies_table) |>
  fmt_number(columns = votes, suffixing = TRUE, decimals = 0) |>
  tab_header(title = "Top 10 highly rated movies with the word 'Monster' in the title",
             subtitle = "Above 10,000 IMDB ratings") |>
  tab_options(table.width = "360px",
              heading.align = "left",
              heading.title.font.weight = "bold",
              table.border.top.style = "none",
              table.border.bottom.style = "none",
              row_group.border.bottom.style = "none",
              data_row.padding = "0px",
              footnotes.padding = "0px",
              source_notes.padding = "0px",
              column_labels.padding = "0px",
              column_labels.font.size = "14px",
              column_labels.border.top.width = 1,
              column_labels.border.top.color = "white",
              column_labels.border.bottom.width = 1,
              column_labels.border.bottom.color = "gray",
              column_labels.text_transform = "capitalize") |>
  opt_table_font("PT Sans") |>
  tab_style(
    style = cell_text(color = "black", weight = "bold", align = "left"),
    locations = cells_title("title")
  ) |>
  tab_footnote("Source: IMDB Dataset, Tidy Tuesday") |>
  tab_source_note("Credit: Joe Chelladurai") |>
  gtsave("monster_movies_table.png", expand = 0)