Visits to the dentists and caries

Author

Sergio Uribe

pacman::p_load(tidyverse, 
               ggrepel, 
               countrycode)
df <- read_csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vQx0EAzcq52X0nGCMkBjG7xWj8mvMIFaoVFIJynfeVuH4bYMW4Hua2zQmefpAb1mLT7S5ZP07ILmOx4/pub?gid=607460752&single=true&output=csv")
New names:
Rows: 31 Columns: 7
── Column specification
──────────────────────────────────────────────────────── Delimiter: "," chr
(3): Country...1, DMFT Index (12-year-olds, latest available), Country...4 dbl
(4): Average Annual Visits per Person...2, Average Annual Visits per Per...
ℹ 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.
• `Country` -> `Country...1`
• `Average Annual Visits per Person` -> `Average Annual Visits per Person...2`
• `Country` -> `Country...4`
• `Average Annual Visits per Person` -> `Average Annual Visits per Person...5`
df <- df |> 
  select(Country = Country...1, 
         "Average Annual Visits" = `Average Annual Visits per Person...2`, 
         DMFT = `DMFT Index Number`)
# Add continent column
df <- df |> 
  mutate(
    Continent = countrycode(
      sourcevar = Country,
      origin = "country.name",
      destination = "continent"
    )
  )
df |> 
  ggplot(aes(x = `Average Annual Visits`, 
             y = DMFT,
             color = Continent)) +  # Add color by continent
  geom_point(size = 2.5, alpha = 0.7) +  # Points colored by continent
  geom_text_repel(
    aes(label = Country),  # Country labels
    size = 3,
    max.overlaps = Inf,
    box.padding = 0.5,
    point.padding = 0.3,
    segment.color = "grey50",
    segment.size = 0.3,
    show.legend = FALSE  # Hide legend for text labels
  ) +
  scale_color_viridis_d(option = "D") +  # Viridis discrete colors
  theme_minimal() +
  labs(
    x = "Average Annual Visits per Person",
    y = "DMFT Index Number",
    color = "Continent"  # Legend title
  )
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_text_repel()`).

df |> 
  ggplot(aes(x = `Average Annual Visits`, 
             y = DMFT,
             color = Continent)) +  # Add color by continent
  geom_point(size = 2.5, alpha = 0.7) +  # Points colored by continent
  geom_text_repel(
    aes(label = Country),  # Country labels
    size = 3,
    max.overlaps = Inf,
    box.padding = 0.5,
    point.padding = 0.3,
    segment.color = "grey50",
    segment.size = 0.3,
    show.legend = FALSE  # Hide legend for text labels
  ) +
  scale_color_viridis_d(option = "D") +  # Viridis discrete colors
  theme_minimal() +
  labs(
    x = "Average Annual Visits per Person",
    y = "DMFT Index Number",
    color = "Continent"  # Legend title
  ) + 
  facet_grid(Continent ~ .)
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_text_repel()`).