library(gapminder)  #<<

library(gapminder)

gapminder   #<<
# A tibble: 1,704 × 6
   country     continent  year lifeExp      pop gdpPercap
   <fct>       <fct>     <int>   <dbl>    <int>     <dbl>
 1 Afghanistan Asia       1952    28.8  8425333      779.
 2 Afghanistan Asia       1957    30.3  9240934      821.
 3 Afghanistan Asia       1962    32.0 10267083      853.
 4 Afghanistan Asia       1967    34.0 11537966      836.
 5 Afghanistan Asia       1972    36.1 13079460      740.
 6 Afghanistan Asia       1977    38.4 14880372      786.
 7 Afghanistan Asia       1982    39.9 12881816      978.
 8 Afghanistan Asia       1987    40.8 13867957      852.
 9 Afghanistan Asia       1992    41.7 16317921      649.
10 Afghanistan Asia       1997    41.8 22227415      635.
# ℹ 1,694 more rows

library(gapminder)

gapminder |>
  filter(year == 2002)   #<<
# A tibble: 142 × 6
   country     continent  year lifeExp       pop gdpPercap
   <fct>       <fct>     <int>   <dbl>     <int>     <dbl>
 1 Afghanistan Asia       2002    42.1  25268405      727.
 2 Albania     Europe     2002    75.7   3508512     4604.
 3 Algeria     Africa     2002    71.0  31287142     5288.
 4 Angola      Africa     2002    41.0  10866106     2773.
 5 Argentina   Americas   2002    74.3  38331121     8798.
 6 Australia   Oceania    2002    80.4  19546792    30688.
 7 Austria     Europe     2002    79.0   8148312    32418.
 8 Bahrain     Asia       2002    74.8    656397    23404.
 9 Bangladesh  Asia       2002    62.0 135656790     1136.
10 Belgium     Europe     2002    78.3  10311970    30486.
# ℹ 132 more rows

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas")   #<<
# A tibble: 25 × 6
   country            continent  year lifeExp       pop gdpPercap
   <fct>              <fct>     <int>   <dbl>     <int>     <dbl>
 1 Argentina          Americas   2002    74.3  38331121     8798.
 2 Bolivia            Americas   2002    63.9   8445134     3413.
 3 Brazil             Americas   2002    71.0 179914212     8131.
 4 Canada             Americas   2002    79.8  31902268    33329.
 5 Chile              Americas   2002    77.9  15497046    10779.
 6 Colombia           Americas   2002    71.7  41008227     5755.
 7 Costa Rica         Americas   2002    78.1   3834934     7723.
 8 Cuba               Americas   2002    77.2  11226999     6341.
 9 Dominican Republic Americas   2002    70.8   8650322     4564.
10 Ecuador            Americas   2002    74.2  12921234     5773.
# ℹ 15 more rows

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas") |>
  ggplot()   #<<

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas") |>
  ggplot() +
  aes(y = country)   #<<

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas") |>
  ggplot() +
  aes(y = country) +
  aes(x = gdpPercap)   #<<

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas") |>
  ggplot() +
  aes(y = country) +
  aes(x = gdpPercap) +
  aes(yend = country,  #<<
      xend = 0)   #<<

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas") |>
  ggplot() +
  aes(y = country) +
  aes(x = gdpPercap) +
  aes(yend = country,
      xend = 0) +
  geom_segment(color = "red",  #<<
               aes(xend = gdpPercap + 10000))   #<<

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas") |>
  ggplot() +
  aes(y = country) +
  aes(x = gdpPercap) +
  aes(yend = country,
      xend = 0) +
  geom_segment(color = "red",
               aes(xend = gdpPercap + 10000)) +
  geom_segment()   #<<

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas") |>
  ggplot() +
  aes(y = country) +
  aes(x = gdpPercap) +
  aes(yend = country,
      xend = 0) +
  geom_segment(color = "red",
               aes(xend = gdpPercap + 10000)) +
  geom_segment() +
  geom_point(size = 8)   #<<

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas") |>
  ggplot() +
  aes(y = country) +
  aes(x = gdpPercap) +
  aes(yend = country,
      xend = 0) +
  geom_segment(color = "red",
               aes(xend = gdpPercap + 10000)) +
  geom_segment() +
  geom_point(size = 8) +
  aes(color = I("blue"))   #<<

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas") |>
  ggplot() +
  aes(y = country) +
  aes(x = gdpPercap) +
  aes(yend = country,
      xend = 0) +
  geom_segment(color = "red",
               aes(xend = gdpPercap + 10000)) +
  geom_segment() +
  geom_point(size = 8) +
  aes(color = I("blue")) +
  aes(size = I(4))  #<<

library(gapminder)

gapminder |>
  filter(year == 2002) |>
  filter(continent == "Americas") |>
  ggplot() +
  aes(y = country) +
  aes(x = gdpPercap) +
  aes(yend = country,
      xend = 0) +
  geom_segment(color = "red",
               aes(xend = gdpPercap + 10000)) +
  geom_segment() +
  geom_point(size = 8) +
  aes(color = I("blue")) +
  aes(size = I(4))