## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>",
                      fig.width = 7, fig.height = 5)

## ----setup--------------------------------------------------------------------
library(steves)
library(dplyr)
library(ggplot2)

## -----------------------------------------------------------------------------
episodes |>
  count(geo_match)

## ----atlas, fig.height = 6, fig.alt = "Map of Europe with one point per Rick Steves' Europe episode, colored by Bayesian-shrunk IMDB rating and sized by vote count, drawn on a cream and tan background."----
world <- map_data("world")

episodes |>
  filter(!is.na(lat), geo_match %in% c("full", "simple")) |>
  ggplot() +
  geom_polygon(data = world,
               aes(long, lat, group = group),
               fill = "#F5F8FC", color = "#B5C7DB", linewidth = 0.2) +
  geom_point(aes(long, lat, color = imdb_rating_shrunk,
                 size = imdb_votes),
             alpha = 0.85) +
  coord_quickmap(xlim = c(-15, 45), ylim = c(34, 65)) +
  scale_color_gradient(low = "#FFC72C", high = "#1B3A6B",
                       name = "Shrunk\nrating") +
  scale_size_continuous(range = c(1.5, 6), name = "Votes") +
  labs(title = "Rick Steves' Europe — episode locations",
       subtitle = "Color: Bayesian-shrunk IMDB rating · Size: vote count",
       x = NULL, y = NULL) +
  theme_void() +
  theme(plot.background  = element_rect(fill = "#FAF6EE", color = NA),
        panel.background = element_rect(fill = "#FAF6EE", color = NA),
        plot.title       = element_text(family = "serif",
                                        face = "bold", size = 16),
        plot.subtitle    = element_text(family = "serif", size = 11))

## ----repeats------------------------------------------------------------------
episodes |>
  count(primary_destination, sort = TRUE) |>
  filter(n > 1) |>
  head(10)

