Skip to content

Instantly share code, notes, and snippets.

@fauxneticien
Created October 25, 2017 12:10
Show Gist options
  • Select an option

  • Save fauxneticien/cb19b958b8cf3cfcf7a0d0ee62ac3e60 to your computer and use it in GitHub Desktop.

Select an option

Save fauxneticien/cb19b958b8cf3cfcf7a0d0ee62ac3e60 to your computer and use it in GitHub Desktop.
Visualise number of speakers of Australian languages in R
library(tidyverse)
library(leaflet)
lang_dialects <- read_csv(
# CSV file of languages with region, latitude and longitude
file = "https://git.io/vFeOj"
)
abs_2016 <- read_csv(
# CSBV file of ABS 2016 census data with language names and number of speakers
file = "https://git.io/vFe3e",
skip = 11,
n_max = 1427,
col_names = c("INGP", "LANP4", "Persons", "X4"),
col_types = "ccic"
)
lang_geo_speakers <- left_join(
x = lang_dialects %>%
filter(macroarea == "Australia") %>%
select(language = name,
longitude,
latitude),
y = abs_2016 %>%
group_by(LANP4) %>%
summarise(speakers = sum(Persons)) %>%
rename(language = LANP4),
by = "language"
)
lang_geo_speakers %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(
label = ~ as.character(paste0(language, ": ", speakers)),
color = ~ ifelse(is.na(speakers), "red", "green")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment