data-raw/pxweb_births.R

## Read data directly from Statistics Greenland website using 'pxweb'

library(pxweb)
library(dplyr)

url <- "https://bank.stat.gl/api/v1/en/Greenland/BE/BE80/BEXFERTR.PX"



query <- list(area = "ALL",
              "mother's year of birth" = as.character(1950:2006), 
              "mother's age" = "*",
              gender = c("K", "M"),
              time = as.character(2011:2020))

pxweb_births <- pxweb_get(url = url,
                          query = query) %>%
    as.data.frame(column.name.type = "text",
                  variable.value.type = "text")

saveRDS(pxweb_births,
        file = "data-raw/pxweb_births.rds")
ONSdigital/Bayesian-demographic-accounts documentation built on Jan. 10, 2022, 12:34 a.m.