An open API service indexing awesome lists of open source software.

https://github.com/ropenspain/tidycenso

An R library for accesing the 2021 spanish census API.
https://github.com/ropenspain/tidycenso

api census r spain

Last synced: 3 months ago
JSON representation

An R library for accesing the 2021 spanish census API.

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# tidycenso

[![R-CMD-check](https://github.com/rOpenSpain/tidycenso/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rOpenSpain/tidycenso/actions/workflows/R-CMD-check.yaml) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![rOS-badge](https://ropenspain.github.io/rostemplate/reference/figures/ropenspain-badge.svg)](https://ropenspain.es/)

## Overview

`tidycenso` is an R library for accessing the 2021 Spanish census API.

## Installation

```{r, eval=FALSE}
devtools::install_github("ropenspain/tidycenso")
```

## Usage

`tidycenso` only has one function: `get_censo`. It admits 4 parameters:

1. `table`: A string of length 1 with the table name to query data from
2. `variables`: A string with variable names of the queried table. If more than one, must be provided using c() (max. 4)
3. `metrics`: A string with the units of measurement of the queried data. If more than one, must be provided concatenated using `c()`
4. `language`: The language used in the request body (the only valid values are 'EN' or 'ES')

The ids and descriptions of the available tables, variables and units of measurement (metrics) are accessible through internal data objects named `tables`, `variables`, and `metrics`.

## Example
```{r include=FALSE}
library(tidycenso)
```

```{r echo=TRUE}
df <- get_censo("hog", c("ID_SUP_VIV", "ID_RESIDENCIA_N1"), "SHOGARES")
head(df)

tidycenso::tables
```