-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
57 lines (38 loc) · 1.66 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# tidycenso
<!-- badges: start -->
[![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/)
<!-- badges: end -->
## 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
```