### which countries speak the most languages?africa %>%group_by(country) %>%summarise(n_languages =n_distinct(language)) %>%ggplot(aes(x = n_languages, y = country)) +geom_col()
3. DATA TIDYING
Code
### df with countsafrica_langs <- africa |>group_by(country) |>summarise(n_languages =n_distinct(language))### africa boundariesafrica_map <-ne_countries(continent ="Africa",scale ="medium") |>select(name_en, geometry) |>mutate(name_en =case_when( name_en =="The Gambia"~"Gambia", name_en =="Democratic Republic of the Congo"~"Congo",TRUE~ name_en ) )### join datasetsafrica_data <- africa_map |>left_join(africa_langs, by =c("name_en"="country"))### check names mismatchafrica_data %>%filter(is.na(n_languages)) |>pull(name_en)
[1] "Somaliland" "São Tomé and Príncipe" "Western Sahara"
[4] "Guinea-Bissau" "Republic of the Congo"
Code
### fix mismatchingafrica_map <-ne_countries(continent ="Africa",scale ="medium") |>select(name_en, geometry) |>mutate(name_en =case_when( name_en =="The Gambia"~"Gambia", name_en =="Democratic Republic of the Congo"~"Congo", name_en =="Republic of the Congo"~"Congo-Brazzaville", name_en =="São Tomé and Príncipe"~"Sao Tome and Principe", name_en =="Guinea-Bissau"~"Guinea Bissau",TRUE~ name_en ) )
4. PLOT
Code
background_col <-"#f9f9f9"#"#FDFDFD", #"#f5f5f2"title_col <-"gray20"subtitle_col <-"gray30"text_col <-"gray30"col <- viridisLite::plasma(100)font_add_google("Bebas Neue", "bebas")font_add_google("Roboto", "roboto")# font_add_google("Font Name", "font_var")showtext_auto()title_font <-"bebas"body_font <-"roboto"title <-"LINGUISTIC DIVERSITY ACROSS AFRICA"subtitle <-"Number of distinct languages spoken per country"# brand <- branding(#github = "anabodevan",#bluesky = "1141bode.bsky.social",#text_size = "13pt",#icon_size = "13pt",#text_color = "gray40",#icon_color = "gray40",#line_spacing = 2L,#text_position = "after",#additional_text = "#TidyTuesday 2026 | Wikipedia: Languages of Africa",#additional_text_size = "10pt",#additional_text_color = "gray40",#text_family = body_font)