library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.1     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.3     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
✔ purrr     1.2.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dslabs)
library(treemap)
# Step 1
filtered_07 <- gapminder |>
  filter(year == 2007)
#Grouping by continent
grouped_07 <- filtered_07 |>
  group_by(continent) %>%
  summarise(total_pop_07 = sum(population, na.rm = TRUE))
#Creating tree map

treemap(
  grouped_07,
  index = "continent",        
  vSize = "total_pop_07",  
  type = "index",
  title = "Total Population by Continent"
)