## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE ) ## ----------------------------------------------------------------------------- # library(pixieweb) # # scb <- px_api("scb", lang = "en") # scb ## ----------------------------------------------------------------------------- # tables <- get_tables(scb, query = "population") # tables ## ----------------------------------------------------------------------------- # tables |> # table_search("municipal") |> # table_describe(max_n = 3, format = "md") ## ----------------------------------------------------------------------------- # vars <- get_variables(scb, "TAB683") # vars |> variable_describe() ## ----------------------------------------------------------------------------- # vars |> variable_values("Region") ## ----------------------------------------------------------------------------- # pop <- get_data(scb, "TAB638", # Region = c("0180", "1480"), # ContentsCode = "*", # Tid = px_top(5) # ) # pop ## ----------------------------------------------------------------------------- # q <- prepare_query(scb, "TAB638", Region = c("0180", "1480")) ## ----------------------------------------------------------------------------- # pop <- get_data(scb, query = q) ## ----------------------------------------------------------------------------- # q <- prepare_query(scb, "TAB638", # Region = c("0180"), # maximize_selection = TRUE # ) ## ----------------------------------------------------------------------------- # library(ggplot2) # # pop |> # ggplot(aes(x = Tid, y = value, colour = Region_text)) + # # One line per region # geom_line(aes(group = Region_text)) + # # Separate panel for each measure (Population, Deaths, etc.) # facet_wrap(~ ContentsCode_text, scales = "free_y") + # # Rotate x-axis labels to avoid overlap # theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1)) + # labs( # title = "Population over time", # caption = px_cite(pop) # Auto-generated data citation # )