├── .github
├── .gitignore
├── FUNDING.yml
└── workflows
│ ├── R-CMD-check.yaml
│ └── r.yml
├── codecov.yml
├── LICENSE
├── _pkgdown.yml
├── tests
├── testthat.R
└── testthat
│ ├── test-mm.R
│ ├── test-get_sinim_var_name.R
│ ├── test-get_sinim_cats.R
│ ├── test-get_sinim_vars.R
│ ├── test-search_sinim_vars.R
│ └── test-get_sinim.R
├── data
├── id_geo_census.rda
├── census_geometry_comunas.rda
└── census_geometry_limites.rda
├── docs
├── reference
│ ├── Rplot001.png
│ ├── figures
│ │ ├── sinimR_hexSticker.png
│ │ ├── unnamed-chunk-13-1.png
│ │ ├── unnamed-chunk-14-1.png
│ │ ├── unnamed-chunk-15-1.png
│ │ └── unnamed-chunk-2-1.png
│ ├── sinimr.html
│ ├── census_geometry_comunas.html
│ ├── census_geometry_limites.html
│ ├── idgeocensus.html
│ ├── id_geo_census.html
│ ├── mm.html
│ ├── get_sinim_vars.html
│ ├── getsinimvariables.html
│ ├── get_sinim_var_name.html
│ ├── index.html
│ ├── getsinimcategories.html
│ └── get_sinim_cats.html
├── pkgdown.yml
├── index_files
│ └── figure-html
│ │ └── unnamed-chunk-6-1.png
├── link.svg
├── sitemap.xml
├── bootstrap-toc.css
├── docsearch.js
├── pkgdown.js
├── articles
│ ├── index.html
│ └── creating-geofacets.html
├── 404.html
├── bootstrap-toc.js
├── news
│ └── index.html
├── authors.html
├── LICENSE-text.html
├── pkgdown.css
└── docsearch.css
├── man
├── figures
│ ├── sinimR_hexSticker.png
│ ├── unnamed-chunk-13-1.png
│ ├── unnamed-chunk-14-1.png
│ ├── unnamed-chunk-15-1.png
│ └── unnamed-chunk-2-1.png
├── get_sinim_cats.Rd
├── mm.Rd
├── get_sinim_vars.Rd
├── get_sinim_var_name.Rd
├── search_sinim_vars.Rd
├── census_geometry_comunas.Rd
├── census_geometry_limites.Rd
├── id_geo_census.Rd
└── get_sinim.Rd
├── R
├── mm.R
├── get_sinim_var_name.R
├── get_sinim_cats.R
├── get_sinim_vars.R
├── search_sinim_vars.R
├── data.R
├── helpers.R
└── get_sinim.R
├── NAMESPACE
├── NEWS.md
├── sandbox
├── auc_test.R
├── join_limite_urbano.R
├── facets.R
├── auc_fastest_plot.R
├── adding_auc.R
└── fastest_plot.R
├── DESCRIPTION
├── .gitignore
└── README.Rmd
/.github/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | comment: false
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | YEAR: 2024
2 | COPYRIGHT HOLDER: Roberto Salas
--------------------------------------------------------------------------------
/_pkgdown.yml:
--------------------------------------------------------------------------------
1 | title: sinimR
2 | template:
3 | params:
4 | bootswatch: flatly
5 |
--------------------------------------------------------------------------------
/tests/testthat.R:
--------------------------------------------------------------------------------
1 | library(testthat)
2 | library(sinimr)
3 |
4 | test_check("sinimr")
5 |
--------------------------------------------------------------------------------
/data/id_geo_census.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/data/id_geo_census.rda
--------------------------------------------------------------------------------
/docs/reference/Rplot001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/docs/reference/Rplot001.png
--------------------------------------------------------------------------------
/data/census_geometry_comunas.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/data/census_geometry_comunas.rda
--------------------------------------------------------------------------------
/data/census_geometry_limites.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/data/census_geometry_limites.rda
--------------------------------------------------------------------------------
/docs/pkgdown.yml:
--------------------------------------------------------------------------------
1 | pandoc: '3.4'
2 | pkgdown: 2.1.0
3 | pkgdown_sha: ~
4 | articles: {}
5 | last_built: 2025-06-30T20:34Z
6 |
--------------------------------------------------------------------------------
/man/figures/sinimR_hexSticker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/man/figures/sinimR_hexSticker.png
--------------------------------------------------------------------------------
/man/figures/unnamed-chunk-13-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/man/figures/unnamed-chunk-13-1.png
--------------------------------------------------------------------------------
/man/figures/unnamed-chunk-14-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/man/figures/unnamed-chunk-14-1.png
--------------------------------------------------------------------------------
/man/figures/unnamed-chunk-15-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/man/figures/unnamed-chunk-15-1.png
--------------------------------------------------------------------------------
/man/figures/unnamed-chunk-2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/man/figures/unnamed-chunk-2-1.png
--------------------------------------------------------------------------------
/docs/reference/figures/sinimR_hexSticker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/docs/reference/figures/sinimR_hexSticker.png
--------------------------------------------------------------------------------
/docs/reference/figures/unnamed-chunk-13-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/docs/reference/figures/unnamed-chunk-13-1.png
--------------------------------------------------------------------------------
/docs/reference/figures/unnamed-chunk-14-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/docs/reference/figures/unnamed-chunk-14-1.png
--------------------------------------------------------------------------------
/docs/reference/figures/unnamed-chunk-15-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/docs/reference/figures/unnamed-chunk-15-1.png
--------------------------------------------------------------------------------
/docs/reference/figures/unnamed-chunk-2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/docs/reference/figures/unnamed-chunk-2-1.png
--------------------------------------------------------------------------------
/docs/index_files/figure-html/unnamed-chunk-6-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/robsalasco/sinimr/HEAD/docs/index_files/figure-html/unnamed-chunk-6-1.png
--------------------------------------------------------------------------------
/tests/testthat/test-mm.R:
--------------------------------------------------------------------------------
1 | context("test-sinimr.R")
2 |
3 | test_that("mm returns a valid output", {
4 |
5 | var <- mm(5807587000)
6 |
7 | expect_is(var, "character")
8 | })
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | custom: ['https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=WDDLRUVD344XL¤cy_code=USD&source=url']
4 |
--------------------------------------------------------------------------------
/tests/testthat/test-get_sinim_var_name.R:
--------------------------------------------------------------------------------
1 | context("test-sinimr.R")
2 |
3 | test_that("get_sinim_var_name returns a valid output", {
4 |
5 | varname <- get_sinim_var_name("ingreso")
6 |
7 | expect_is(varname, "character")
8 | })
--------------------------------------------------------------------------------
/tests/testthat/test-get_sinim_cats.R:
--------------------------------------------------------------------------------
1 | context("test-sinimr.R")
2 |
3 | test_that("get_sinim_cats returns a valid output", {
4 |
5 | cat <- get_sinim_cats()
6 |
7 | expect_is(cat, "list")
8 | expect_output(str(cat), "List of 10")
9 | })
--------------------------------------------------------------------------------
/tests/testthat/test-get_sinim_vars.R:
--------------------------------------------------------------------------------
1 | context("test-sinimr.R")
2 |
3 | test_that("get_sinim_vars returns a valid output", {
4 |
5 | tbl <- get_sinim_vars(262)
6 |
7 | expect_is(tbl, "data.frame")
8 | expect_output(str(tbl), "22 obs. of 3 variables")
9 | })
--------------------------------------------------------------------------------
/tests/testthat/test-search_sinim_vars.R:
--------------------------------------------------------------------------------
1 | context("test-sinimr.R")
2 |
3 | test_that("search_sinim_vars returns a valid output", {
4 |
5 | srch <- search_sinim_vars("ingreso")
6 |
7 | expect_is(srch, "data.frame")
8 | expect_output(str(srch), "81 obs. of 6 variables")
9 | })
--------------------------------------------------------------------------------
/R/mm.R:
--------------------------------------------------------------------------------
1 | #' Return a abbreviated value of the "miles de millones" format
2 | #'
3 | #' @param x Numeric value to convert
4 | #'
5 | #' @return A character value in short format
6 | #' @export
7 | #'
8 | #' @examples
9 | #' mm(5807587000)
10 | mm <- function(x) {
11 | y <- paste0(formatC(x/1e9, digits = 0, format = "f"), " mm$")
12 | return(y)
13 | }
--------------------------------------------------------------------------------
/R/get_sinim_var_name.R:
--------------------------------------------------------------------------------
1 | #' Return SINIM variable name using their internal codes
2 | #'
3 | #' @param var Variable code
4 | #'
5 | #' @return A vector of requested variable names
6 | #' @export
7 | #' @examples
8 | #' get_sinim_var_name(880)
9 | #' get_sinim_var_name(c(880, 882))
10 | get_sinim_var_name <- function(var) {
11 | x <- getname(var)
12 |
13 | return(x)
14 | }
--------------------------------------------------------------------------------
/NAMESPACE:
--------------------------------------------------------------------------------
1 | # Generated by roxygen2: do not edit by hand
2 |
3 | export(get_sinim)
4 | export(get_sinim_cats)
5 | export(get_sinim_var_name)
6 | export(get_sinim_vars)
7 | export(mm)
8 | export(search_sinim_vars)
9 | import(XML)
10 | import(httr)
11 | import(sf)
12 | importFrom(jsonlite,fromJSON)
13 | importFrom(reshape2,melt)
14 | importFrom(stats,complete.cases)
15 | importFrom(stats,na.omit)
16 | importFrom(stats,reshape)
17 |
--------------------------------------------------------------------------------
/man/get_sinim_cats.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_sinim_cats.R
3 | \name{get_sinim_cats}
4 | \alias{get_sinim_cats}
5 | \title{Get SINIM data categories}
6 | \usage{
7 | get_sinim_cats()
8 | }
9 | \value{
10 | Returns a data frame with available data in SINIM's webpage
11 | }
12 | \description{
13 | Get SINIM data categories
14 | }
15 | \examples{
16 | get_sinim_cats()
17 | }
18 |
--------------------------------------------------------------------------------
/NEWS.md:
--------------------------------------------------------------------------------
1 | # sinimr 0.3.5
2 |
3 | * More changes for CRAN submission
4 |
5 | # sinimr 0.3.4
6 |
7 | * Preparing CRAN submission
8 |
9 | # sinimr 0.3.3
10 |
11 | * Fixed github bug #7 and #8
12 |
13 | # sinimr 0.3.2
14 |
15 | * Fixed and updated GitHub action
16 | * Updated site
17 | * Added docs for data
18 | * Added a `NEWS.md` file to track changes to the package.
19 |
20 | # sinimr 0.3.1
21 |
22 | * Fixed error on get_sinim_vars() function
23 |
--------------------------------------------------------------------------------
/man/mm.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/mm.R
3 | \name{mm}
4 | \alias{mm}
5 | \title{Return a abbreviated value of the "miles de millones" format}
6 | \usage{
7 | mm(x)
8 | }
9 | \arguments{
10 | \item{x}{Numeric value to convert}
11 | }
12 | \value{
13 | A character value in short format
14 | }
15 | \description{
16 | Return a abbreviated value of the "miles de millones" format
17 | }
18 | \examples{
19 | mm(5807587000)
20 | }
21 |
--------------------------------------------------------------------------------
/R/get_sinim_cats.R:
--------------------------------------------------------------------------------
1 | #' Get SINIM data categories
2 | #' @return Returns a data frame with available data in SINIM's webpage
3 | #' @export
4 | #' @examples
5 | #' get_sinim_cats()
6 |
7 | get_sinim_cats <- function() {
8 | body <- list("dato_area[]" = "T")
9 | resp <- postapi("https://datos.sinim.gov.cl/datos_municipales/obtener_datos_filtros.php", body)
10 | out <- lapply(resp, function(x) data.frame(variable = x$nombre_subarea, code = x$id_subarea))
11 |
12 | return(out)
13 | }
14 |
--------------------------------------------------------------------------------
/man/get_sinim_vars.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_sinim_vars.R
3 | \name{get_sinim_vars}
4 | \alias{get_sinim_vars}
5 | \title{List available variables for a category}
6 | \usage{
7 | get_sinim_vars(catn)
8 | }
9 | \arguments{
10 | \item{catn}{category number}
11 | }
12 | \value{
13 | data frame with variables and values
14 | }
15 | \description{
16 | List available variables for a category
17 | }
18 | \examples{
19 | get_sinim_vars(47)
20 | }
21 |
--------------------------------------------------------------------------------
/man/get_sinim_var_name.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_sinim_var_name.R
3 | \name{get_sinim_var_name}
4 | \alias{get_sinim_var_name}
5 | \title{Return SINIM variable name using their internal codes}
6 | \usage{
7 | get_sinim_var_name(var)
8 | }
9 | \arguments{
10 | \item{var}{Variable code}
11 | }
12 | \value{
13 | A vector of requested variable names
14 | }
15 | \description{
16 | Return SINIM variable name using their internal codes
17 | }
18 | \examples{
19 | get_sinim_var_name(880)
20 | get_sinim_var_name(c(880, 882))
21 | }
22 |
--------------------------------------------------------------------------------
/man/search_sinim_vars.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/search_sinim_vars.R
3 | \name{search_sinim_vars}
4 | \alias{search_sinim_vars}
5 | \title{Search for a SINIM variable and if no keyword is provided returns all variables}
6 | \usage{
7 | search_sinim_vars(keyword)
8 | }
9 | \arguments{
10 | \item{keyword}{keyword}
11 | }
12 | \value{
13 | data frame with results
14 | }
15 | \description{
16 | Search for a SINIM variable and if no keyword is provided returns all variables
17 | }
18 | \examples{
19 | search_sinim_vars("ingresos propios")
20 | }
21 |
--------------------------------------------------------------------------------
/man/census_geometry_comunas.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/data.R
3 | \docType{data}
4 | \name{census_geometry_comunas}
5 | \alias{census_geometry_comunas}
6 | \title{Chilean municipalities polygons as simple features}
7 | \format{
8 | A data frame with 345 rows and 2 variables:
9 | \describe{
10 | \item{code}{municipality code}
11 | \item{geometry}{municipality geometry}
12 | }
13 | }
14 | \source{
15 | \url{http://www.ine.cl/}
16 | }
17 | \usage{
18 | census_geometry_comunas
19 | }
20 | \description{
21 | An sf object containing the chilean municipalities.
22 | }
23 | \keyword{datasets}
24 |
--------------------------------------------------------------------------------
/man/census_geometry_limites.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/data.R
3 | \docType{data}
4 | \name{census_geometry_limites}
5 | \alias{census_geometry_limites}
6 | \title{Chilean municipalities urban boundaries polygons as simple features}
7 | \format{
8 | A data frame with 220 rows and 2 variables:
9 | \describe{
10 | \item{code}{municipality code}
11 | \item{geometry}{municipality geometry}
12 | }
13 | }
14 | \source{
15 | \url{http://www.ine.cl/}
16 | }
17 | \usage{
18 | census_geometry_limites
19 | }
20 | \description{
21 | An sf object containing the chilean municipalities urban boundaries.
22 | }
23 | \keyword{datasets}
24 |
--------------------------------------------------------------------------------
/sandbox/auc_test.R:
--------------------------------------------------------------------------------
1 | library(sf)
2 | library(sinimr)
3 | library(magrittr)
4 | library(mapview)
5 | library(dplyr)
6 | library(leafsync)
7 | fh <- read_sf("/Users/robsalasco/Downloads/AUC-1/AUC2017.shp") %>%
8 | filter(CIUDAD=="GRAN SANTIAGO") %>% select(OBJECTID)
9 |
10 | st_crs(fh)
11 | fh <- fh %>% st_transform(4326)
12 |
13 | ffs <- st_intersects(census_geometry_limites, fh, sparse = FALSE)
14 |
15 | (id_geo_census %>% filter(CODE %in% census_geometry_limites[which(as.logical(ffs)), ]$CODE))$MUNICIPALITY
16 |
17 | selection <- census_geometry_limites[which(as.logical(ffs)), ]
18 |
19 | m1 <- mapview(fh)
20 | m2 <- mapview(selection)
21 |
22 | latticeView(m1, m2, ncol = 2, sync = list(c(1, 2)), sync.cursor = FALSE, no.initial.sync = FALSE)
23 |
24 |
--------------------------------------------------------------------------------
/man/id_geo_census.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/data.R
3 | \docType{data}
4 | \name{id_geo_census}
5 | \alias{id_geo_census}
6 | \title{Chilean administrative divisions}
7 | \format{
8 | A data frame with 345 rows and 7 variables:
9 | \describe{
10 | \item{code}{municipality code}
11 | \item{municipality}{municipality name}
12 | \item{code.reg}{region code}
13 | \item{nom.reg}{region name}
14 | \item{code.prov}{province code}
15 | \item{nom.prov}{province name}
16 | \item{auc}{yes/no consolidated urban area}
17 | }
18 | }
19 | \source{
20 | \url{http://www.ine.cl/}
21 | }
22 | \usage{
23 | id_geo_census
24 | }
25 | \description{
26 | A dataset containing the chilean administrative units.
27 | }
28 | \keyword{datasets}
29 |
--------------------------------------------------------------------------------
/sandbox/join_limite_urbano.R:
--------------------------------------------------------------------------------
1 | library(sf)
2 | library(dplyr)
3 |
4 | # https://es.wikipedia.org/wiki/Áreas_metropolitanas_y_conurbaciones_de_Chile
5 |
6 | dat <- lapply(paste0("R",
7 | sprintf("%02d", 1:15)),
8 | function(x) {
9 | read_sf(
10 | paste0(
11 | "https://raw.githubusercontent.com/robsalasco/precenso_2016_geojson_chile/master/Limite_Urbano/",
12 | x,
13 | ".geojson"
14 | )
15 | )
16 | })
17 |
18 | chl <- do.call(rbind, dat)
19 |
20 | chl %>% filter(CATEGORIA=="CIUDAD") %>%
21 | group_by(COMUNA) %>%
22 | summarize() %>%
23 | st_cast("MULTIPOLYGON") %>% mutate(COMUNA=as.numeric(COMUNA)) %>%
24 | arrange(COMUNA)
25 |
--------------------------------------------------------------------------------
/docs/link.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/R/get_sinim_vars.R:
--------------------------------------------------------------------------------
1 | #' List available variables for a category
2 | #' @param catn category number
3 | #' @return data frame with variables and values
4 | #' @export
5 | #' @examples
6 | #' get_sinim_vars(47)
7 |
8 | get_sinim_vars <- function(catn) {
9 |
10 | stopifnot(is.numeric(catn))
11 | stopifnot(catn > 0)
12 |
13 | body <- list("dato_area[]" = "T", "dato_subarea[]" = "T")
14 | resp <- postapi(
15 | "https://datos.sinim.gov.cl/datos_municipales/obtener_datos_filtros.php",
16 | body
17 | )
18 | list <- Reduce(function(...) merge(..., all = T), resp)
19 | sub <- as.vector(subset(list, id_subarea == catn, select = c("mtro_datos_nombre", "unidad_medida_simbolo", "id_dato")))
20 | sub_df <- as.data.frame(sub)
21 | colnames(sub_df) <- c("variable", "unit", "code")
22 |
23 | stopifnot(nrow(sub_df) > 0)
24 |
25 | return(sub_df)
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/.github/workflows/R-CMD-check.yaml:
--------------------------------------------------------------------------------
1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3 | on:
4 | push:
5 | branches: [main, master]
6 | pull_request:
7 | branches: [main, master]
8 |
9 | name: R-CMD-check
10 |
11 | jobs:
12 | R-CMD-check:
13 | runs-on: ubuntu-latest
14 | env:
15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
16 | R_KEEP_PKG_SOURCE: yes
17 | steps:
18 | - uses: actions/checkout@v2
19 |
20 | - uses: r-lib/actions/setup-r@v2
21 | with:
22 | use-public-rspm: true
23 |
24 | - uses: r-lib/actions/setup-r-dependencies@v2
25 | with:
26 | extra-packages: any::rcmdcheck, any::XML
27 | needs: check
28 |
29 | - uses: r-lib/actions/check-r-package@v2
30 |
--------------------------------------------------------------------------------
/sandbox/facets.R:
--------------------------------------------------------------------------------
1 | tm <- get_sinim(var, year, geometry = T, truevalue = T, idgeo = T, unit = "comunas") %>%
2 | filter(!(CODE %in% c(5201,5104))) %>%
3 | tm_shape() +
4 | tm_fill(col = "VALUE",
5 | title=get_sinim_var_name(var),
6 | palette = "PuRd",
7 | border.col = "white",
8 | style = "pretty")+
9 | #tm_text("MUNICIPALITY", size = 0.4) +
10 | tm_layout(legend.format = list(text.separator = "a", fun = mm),
11 | legend.outside=T, outer.margins = c(0.05,0.10,0.05,0.10),
12 | inner.margins = c(0.01,0.1,0.08,0.01)) +
13 | tm_grid(labels.inside.frame = F, col = "#d3d3d3", alpha = 0.25, labels.size = 0.8, n.x=7, n.y=7) +
14 | tm_borders(col = 'black')+
15 | tm_scale_bar(position = c("left","bottom")) +
16 | tm_facets(by="NOM.REG",ncol=2)
17 |
18 | tmap_save(tm, "map.png", width = 24, height = 12, units = "in")
19 |
--------------------------------------------------------------------------------
/sandbox/auc_fastest_plot.R:
--------------------------------------------------------------------------------
1 | library(tmap)
2 | library(sinimr)
3 |
4 | get_sinim(880, 2018, region=13, geometry=T, truevalue = T, auc = T, unit = "limites") %>%
5 | tm_shape() +
6 | tm_fill(col = "VALUE",
7 | title=get_sinim_var_name(880),
8 | palette = "PuRd",
9 | border.col = "white",
10 | style = "pretty")+
11 | tm_text("MUNICIPALITY", size = 0.4) +
12 | tm_layout(legend.format = list(text.separator = "a", fun = mm),
13 | legend.outside=F, outer.margins = c(0.05,0.10,0.05,0.10),
14 | inner.margins = c(0.01,0.1,0.08,0.01)) +
15 | tm_grid(labels.inside.frame = F, col = "#d3d3d3", alpha = 0.25, labels.size = 0.8, n.x=7, n.y=7) +
16 | tm_borders(col = 'black')+
17 | tm_compass(position=c("left", "top")) +
18 | tm_scale_bar(position = c("left","bottom"))
19 |
20 | get_sinim(880, 2018, provincia = 14, auc=T, unit = "limites")
21 |
--------------------------------------------------------------------------------
/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Package: sinimr
2 | Type: Package
3 | Title: Chilean Municipalities Information System Wrapper
4 | Version: 0.3.5
5 | Date: 2025-07-02
6 | Authors@R: c(person("Roberto", "Salas", email =
7 | "rosalas@uc.cl", role = c("aut", "cre"),
8 | comment = c(ORCID = "0000-0001-9607-3930")))
9 | Description: Provides access to Chilean municipal data from SINIM.
10 | License: MIT + file LICENSE
11 | LazyData: true
12 | Imports:
13 | httr (>= 1.3.1),
14 | jsonlite (>= 1.5),
15 | XML (>= 3.98-1.16),
16 | reshape2 (>= 1.4.3),
17 | stats,
18 | sf
19 | Collate:
20 | get_sinim_cats.R
21 | get_sinim.R
22 | get_sinim_vars.R
23 | get_sinim_var_name.R
24 | search_sinim_vars.R
25 | mm.R
26 | helpers.R
27 | data.R
28 | Encoding: UTF-8
29 | RoxygenNote: 7.2.1
30 | Suggests: testthat,
31 | covr,
32 | rmarkdown
33 | URL: https://github.com/robsalasco/sinimr
34 | BugReports: https://github.com/robsalasco/sinimr/issues
35 |
--------------------------------------------------------------------------------
/R/search_sinim_vars.R:
--------------------------------------------------------------------------------
1 | #' Search for a SINIM variable and if no keyword is provided returns all variables
2 | #' @param keyword keyword
3 | #' @return data frame with results
4 | #' @export
5 | #' @examples
6 | #' search_sinim_vars("ingresos propios")
7 |
8 | search_sinim_vars <- function(keyword) {
9 |
10 |
11 | body <- list("dato_area[]" = "T", "dato_subarea[]" = "T")
12 | resp2 <- postapi("https://datos.sinim.gov.cl/datos_municipales/obtener_datos_filtros.php",
13 | body)
14 | data <- Reduce(function(...) merge(..., all=T), resp2)
15 | data <- data[ ,c(8, 10, 18, 2, 4, 5)]
16 | colnames(data) <- c("code", "variable", "description", "area", "subarea", "unit")
17 |
18 | if (missing(keyword)) {
19 | search <- data
20 | }
21 | else {
22 | stopifnot(is.character(keyword))
23 | search <- data[with(data, grepl(keyword, paste(variable, description, area, subarea), ignore.case = T)), ]
24 | }
25 |
26 | return(search)
27 | }
28 |
--------------------------------------------------------------------------------
/docs/sitemap.xml:
--------------------------------------------------------------------------------
1 |
2 | /404.html
3 | /LICENSE-text.html
4 | /articles/creating-geofacets.html
5 | /articles/index.html
6 | /authors.html
7 | /index.html
8 | /news/index.html
9 | /reference/census_geometry_comunas.html
10 | /reference/census_geometry_limites.html
11 | /reference/get_sinim.html
12 | /reference/get_sinim_cats.html
13 | /reference/get_sinim_var_name.html
14 | /reference/get_sinim_vars.html
15 | /reference/getsinimcategories.html
16 | /reference/getsinimr.html
17 | /reference/getsinimryears.html
18 | /reference/getsinimvariables.html
19 | /reference/id_geo_census.html
20 | /reference/idgeocensus.html
21 | /reference/index.html
22 | /reference/mm.html
23 | /reference/search_sinim_vars.html
24 | /reference/searchsinimvar.html
25 | /reference/sinimr.html
26 |
27 |
28 |
--------------------------------------------------------------------------------
/R/data.R:
--------------------------------------------------------------------------------
1 | #' Chilean administrative divisions
2 | #'
3 | #' A dataset containing the chilean administrative units.
4 | #'
5 | #' @format A data frame with 345 rows and 7 variables:
6 | #' \describe{
7 | #' \item{code}{municipality code}
8 | #' \item{municipality}{municipality name}
9 | #' \item{code.reg}{region code}
10 | #' \item{nom.reg}{region name}
11 | #' \item{code.prov}{province code}
12 | #' \item{nom.prov}{province name}
13 | #' \item{auc}{yes/no consolidated urban area}
14 | #' }
15 | #' @source \url{https://www.ine.cl/}
16 | "id_geo_census"
17 |
18 | #' Chilean municipalities polygons as simple features
19 | #'
20 | #' An sf object containing the chilean municipalities.
21 | #'
22 | #' @format A data frame with 345 rows and 2 variables:
23 | #' \describe{
24 | #' \item{code}{municipality code}
25 | #' \item{geometry}{municipality geometry}
26 | #' }
27 | #' @source \url{https://www.ine.cl/}
28 | "census_geometry_comunas"
29 |
30 | #' Chilean municipalities urban boundaries polygons as simple features
31 | #'
32 | #' An sf object containing the chilean municipalities urban boundaries.
33 | #'
34 | #' @format A data frame with 220 rows and 2 variables:
35 | #' \describe{
36 | #' \item{code}{municipality code}
37 | #' \item{geometry}{municipality geometry}
38 | #' }
39 | #' @source \url{https://www.ine.cl/}
40 | "census_geometry_limites"
--------------------------------------------------------------------------------
/sandbox/adding_auc.R:
--------------------------------------------------------------------------------
1 | library(sinimr)
2 |
3 | auc1 <- c("CERRILLOS", "LA REINA", "PUDAHUEL", "CERRO NAVIA", "LAS CONDES",
4 | "QUILICURA", "CONCHALÍ", "LO BARNECHEA", "QUINTA NORMAL", "EL BOSQUE",
5 | "LO ESPEJO", "RECOLETA", "ESTACIÓN CENTRAL", "LO PRADO", "RENCA", "HUECHURABA",
6 | "MACUL", "SAN MIGUEL", "INDEPENDENCIA", "MAIPÚ", "SAN JOAQUÍN", "LA CISTERNA", "ÑUÑOA",
7 | "SAN RAMÓN", "LA FLORIDA", "PEDRO AGUIRRE CERDA", "SANTIAGO", "LA PINTANA", "PEÑALOLÉN",
8 | "VITACURA", "LA GRANJA", "PROVIDENCIA", "SAN BERNARDO", "PUENTE ALTO", "PADRE HURTADO", "PIRQUE",
9 | "SAN JOSÉ DE MAIPO")
10 |
11 | auc2 <- c("CONCEPCIÓN", "CORONEL", "CHIGUAYANTE", "HUALPÉN", "HUALQUI", "LOTA",
12 | "PENCO", "SAN PEDRO DE LA PAZ", "TALCAHUANO", "TOMÉ")
13 |
14 | auc3 <- c( "VALPARAÍSO", "VIÑA DEL MAR", "QUILPUÉ", "VILLA ALEMANA", "CONCÓN")
15 |
16 | auc4 <- c("LA SERENA", "COQUIMBO")
17 |
18 | auc5 <- c("TEMUCO", "PADRE LAS CASAS")
19 |
20 | auc6 <- c("IQUIQUE","ALTO HOSPICIO")
21 |
22 | auc7 <- c("RANCAGUA", "MACHALÍ", "OLIVAR", "REQUINOA")
23 |
24 | auc8 <- c("PUERTO MONTT")
25 |
26 | auc9 <- c("PUERTO VARAS")
27 |
28 | auc10 <- c("ARICA")
29 |
30 | auc11 <- c("TALCA")
31 |
32 | auc12 <- c("CHILLÁN", "CHILLÁN VIEJO")
33 |
34 | auc13 <- c("LOS ÁNGELES")
35 |
36 | c.list <- c(auc1,auc2,auc3,auc4,auc5,auc6,auc7,auc8,auc9,auc10,auc11,auc12,auc13)
37 |
38 | id_geo_census$AUC <- ifelse(id_geo_census$MUNICIPALITY %in% c.list,1,0)
39 |
40 | save(id_geo_census, file="data/id_geo_census.rda")
41 |
--------------------------------------------------------------------------------
/man/get_sinim.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_sinim.R
3 | \name{get_sinim}
4 | \alias{get_sinim}
5 | \title{Get a SINIM variable data in a specific year as a data frame}
6 | \usage{
7 | get_sinim(
8 | var,
9 | year,
10 | moncorr = T,
11 | truevalue = F,
12 | idgeo = F,
13 | geometry = F,
14 | region,
15 | provincia,
16 | comuna,
17 | auc = F,
18 | unit = "comunas"
19 | )
20 | }
21 | \arguments{
22 | \item{var}{Variable code}
23 |
24 | \item{year}{Year}
25 |
26 | \item{moncorr}{A logical value indicating the use of monetary correction}
27 |
28 | \item{truevalue}{A logical value indicating the use of converted values}
29 |
30 | \item{idgeo}{A logical value to add provincia and region columns}
31 |
32 | \item{geometry}{A logical value to add geographical features}
33 |
34 | \item{region}{Region subsetting variable}
35 |
36 | \item{provincia}{Provincia subsetting variable}
37 |
38 | \item{comuna}{Comuna subsetting variable}
39 |
40 | \item{auc}{A logical value to retrieve only AUC features}
41 |
42 | \item{unit}{Use "comunas" or "limites"}
43 | }
44 | \value{
45 | data frame for the requested variable over time with optional geometry
46 | }
47 | \description{
48 | Get a SINIM variable data in a specific year as a data frame
49 | }
50 | \examples{
51 | get_sinim(880, 2015)
52 | get_sinim(880, 2015:2017)
53 | get_sinim(c(880, 882), 2015)
54 | get_sinim(c(880, 882), 2015:2017)
55 | get_sinim(c(880, 882), 2015, idgeo=TRUE)
56 | get_sinim(882, 2015, geometry=TRUE)
57 | get_sinim(882, 2015, region="02")
58 | }
59 |
--------------------------------------------------------------------------------
/sandbox/fastest_plot.R:
--------------------------------------------------------------------------------
1 | library(sinimr)
2 | library(tmap)
3 | library(dplyr)
4 |
5 | comunas.names <- c("CERRILLOS", "LA REINA", "PUDAHUEL", "CERRO NAVIA", "LAS CONDES",
6 | "QUILICURA", "CONCHALÍ", "LO BARNECHEA", "QUINTA NORMAL", "EL BOSQUE",
7 | "LO ESPEJO", "RECOLETA", "ESTACIÓN CENTRAL", "LO PRADO", "RENCA", "HUECHURABA",
8 | "MACUL", "SAN MIGUEL", "INDEPENDENCIA", "MAIPÚ", "SAN JOAQUÍN", "LA CISTERNA", "ÑUÑOA",
9 | "SAN RAMÓN", "LA FLORIDA", "PEDRO AGUIRRE CERDA", "SANTIAGO", "LA PINTANA", "PEÑALOLÉN",
10 | "VITACURA", "LA GRANJA", "PROVIDENCIA", "SAN BERNARDO", "PUENTE ALTO", "PADRE HURTADO", "PIRQUE",
11 | "SAN JOSÉ DE MAIPO")
12 |
13 | comunas.codes<- filter(id_geo_census, MUNICIPALITY %in% comunas.names) %>% pull(CODE)
14 |
15 | # Variable code
16 | var <- 880
17 | # Variable year
18 | year <- 2018
19 | # Getting data and plotting
20 | tm <- get_sinim(var, year, geometry = T, region=5, truevalue = T, unit = "limites") %>%
21 | filter(!(CODE %in% c(5201,5104))) %>%
22 | tm_shape() +
23 | tm_fill(col = "VALUE",
24 | title=get_sinim_var_name(var),
25 | palette = "PuRd",
26 | border.col = "white",
27 | style = "pretty")+
28 | tm_text("MUNICIPALITY", size = 0.4) +
29 | tm_layout(legend.format = list(text.separator = "a", fun = mm),
30 | legend.outside=F, outer.margins = c(0.05,0.10,0.05,0.10),
31 | inner.margins = c(0.01,0.1,0.08,0.01)) +
32 | tm_grid(labels.inside.frame = F, col = "#d3d3d3", alpha = 0.25, labels.size = 0.8, n.x=7, n.y=7) +
33 | tm_borders(col = 'black')+
34 | tm_compass(position=c("left", "top")) +
35 | tm_scale_bar(position = c("left","bottom"))
36 |
37 | tmap_save(tm, "map.png", width = 10, height = 10, units = "in")
38 |
--------------------------------------------------------------------------------
/.github/workflows/r.yml:
--------------------------------------------------------------------------------
1 | # This workflow uses actions that are not certified by GitHub.
2 | # They are provided by a third-party and are governed by
3 | # separate terms of service, privacy policy, and support
4 | # documentation.
5 | #
6 | # See https://github.com/r-lib/actions/tree/master/examples#readme for
7 | # additional example workflows available for the R community.
8 |
9 | name: R
10 |
11 | on:
12 | push:
13 | branches: [ master ]
14 | pull_request:
15 | branches: [ master ]
16 |
17 | jobs:
18 | test-coverage:
19 | runs-on: ubuntu-18.04
20 | env:
21 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
22 | steps:
23 | - uses: actions/checkout@master
24 | - uses: r-lib/actions/setup-r@v1
25 |
26 | - name: Install system dependencies
27 | run: sudo apt-get install -y libudunits2-dev libgdal-dev
28 |
29 | - name: Query dependencies
30 | run: |
31 | install.packages('remotes')
32 | saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
33 | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
34 | shell: Rscript {0}
35 |
36 | - name: Cache R packages
37 | uses: actions/cache@v2
38 | with:
39 | path: ${{ env.R_LIBS_USER }}
40 | key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
41 | restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
42 |
43 | - name: Install dependencies
44 | run: |
45 | install.packages(c("remotes"))
46 | remotes::install_deps(dependencies = TRUE)
47 | remotes::install_cran("covr")
48 | shell: Rscript {0}
49 |
50 | - name: Test coverage
51 | run: covr::codecov()
52 | shell: Rscript {0}
53 |
54 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Meta
2 | doc
3 | ### R template
4 | # History files
5 | .Rhistory
6 | .Rapp.history
7 |
8 | # Example code in package build process
9 | *-Ex.R
10 | # RStudio files
11 | .Rproj.user/
12 | .RData
13 | *.Rproj
14 | # produced vignettes
15 | vignettes/*.html
16 | vignettes/*.pdf
17 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
18 | .httr-oauth
19 | ### OSX template
20 | .DS_Store
21 | .AppleDouble
22 | .LSOverride
23 | # Icon must end with two \r
24 | Icon
25 | # Thumbnails
26 | ._*
27 | # Files that might appear in the root of a volume
28 | .DocumentRevisions-V100
29 | .fseventsd
30 | .Spotlight-V100
31 | .TemporaryItems
32 | .Trashes
33 | .VolumeIcon.icns
34 | # Directories potentially created on remote AFP share
35 | .AppleDB
36 | .AppleDesktop
37 | Network Trash Folder
38 | Temporary Items
39 | .apdisk
40 | ### JetBrains template
41 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
42 | *.iml
43 | ## Directory-based project format:
44 | .idea/
45 | # if you remove the above rule, at least ignore the following:
46 | # User-specific stuff:
47 | # .idea/workspace.xml
48 | # .idea/tasks.xml
49 | # .idea/dictionaries
50 | # Sensitive or high-churn files:
51 | # .idea/dataSources.ids
52 | # .idea/dataSources.xml
53 | # .idea/sqlDataSources.xml
54 | # .idea/dynamic.xml
55 | # .idea/uiDesigner.xml
56 | # Gradle:
57 | # .idea/gradle.xml
58 | # .idea/libraries
59 | # Mongo Explorer plugin:
60 | # .idea/mongoSettings.xml
61 | ## File-based project format:
62 | *.ipr
63 | *.iws
64 | ## Plugin-specific files:
65 | # IntelliJ
66 | /out/
67 | # mpeltonen/sbt-idea plugin
68 | .idea_modules/
69 | # JIRA plugin
70 | atlassian-ide-plugin.xml
71 | # Crashlytics plugin (for Android Studio and IntelliJ)
72 | com_crashlytics_export_strings.xml
73 | crashlytics.properties
74 | crashlytics-build.properties
75 | # Created by .ignore support plugin (hsz.mobi)
76 | .Rproj.user
77 | # Other
78 | .Rbuildignore
79 | inst/doc
80 |
--------------------------------------------------------------------------------
/docs/bootstrap-toc.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/)
3 | * Copyright 2015 Aidan Feldman
4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */
5 |
6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */
7 |
8 | /* All levels of nav */
9 | nav[data-toggle='toc'] .nav > li > a {
10 | display: block;
11 | padding: 4px 20px;
12 | font-size: 13px;
13 | font-weight: 500;
14 | color: #767676;
15 | }
16 | nav[data-toggle='toc'] .nav > li > a:hover,
17 | nav[data-toggle='toc'] .nav > li > a:focus {
18 | padding-left: 19px;
19 | color: #563d7c;
20 | text-decoration: none;
21 | background-color: transparent;
22 | border-left: 1px solid #563d7c;
23 | }
24 | nav[data-toggle='toc'] .nav > .active > a,
25 | nav[data-toggle='toc'] .nav > .active:hover > a,
26 | nav[data-toggle='toc'] .nav > .active:focus > a {
27 | padding-left: 18px;
28 | font-weight: bold;
29 | color: #563d7c;
30 | background-color: transparent;
31 | border-left: 2px solid #563d7c;
32 | }
33 |
34 | /* Nav: second level (shown on .active) */
35 | nav[data-toggle='toc'] .nav .nav {
36 | display: none; /* Hide by default, but at >768px, show it */
37 | padding-bottom: 10px;
38 | }
39 | nav[data-toggle='toc'] .nav .nav > li > a {
40 | padding-top: 1px;
41 | padding-bottom: 1px;
42 | padding-left: 30px;
43 | font-size: 12px;
44 | font-weight: normal;
45 | }
46 | nav[data-toggle='toc'] .nav .nav > li > a:hover,
47 | nav[data-toggle='toc'] .nav .nav > li > a:focus {
48 | padding-left: 29px;
49 | }
50 | nav[data-toggle='toc'] .nav .nav > .active > a,
51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a,
52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a {
53 | padding-left: 28px;
54 | font-weight: 500;
55 | }
56 |
57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */
58 | nav[data-toggle='toc'] .nav > .active > ul {
59 | display: block;
60 | }
61 |
--------------------------------------------------------------------------------
/tests/testthat/test-get_sinim.R:
--------------------------------------------------------------------------------
1 | context("test-sinimr.R")
2 |
3 | test_that("get_sinim returns a valid output", {
4 |
5 | tbl <- get_sinim(880, 2015)
6 |
7 | expect_is(tbl, "data.frame")
8 | expect_true(is.numeric(tbl$value))
9 | expect_output(str(tbl), "345 obs. of 5 variables")
10 | })
11 |
12 |
13 | test_that("get_sinim returns a character", {
14 |
15 | tbl <- get_sinim(4333, 2017)
16 |
17 | expect_true(is.character(tbl$value))
18 | })
19 |
20 | test_that("get_sinim returns a numeric on mixed", {
21 |
22 | tbl <- get_sinim(c(880, 4210), 2017)
23 |
24 | expect_true(is.numeric(tbl$value))
25 | })
26 |
27 | test_that("get_sinim returns a character on mixed", {
28 |
29 | tbl <- get_sinim(c(4333, 4211), 2017)
30 |
31 | expect_true(is.character(tbl$value))
32 | })
33 |
34 | test_that("get_sinim returns a numeric on failed", {
35 |
36 | tbl <- get_sinim(c(4333, 4211), 2015)
37 |
38 | expect_true(is.numeric(tbl$value))
39 | })
40 |
41 | test_that("get_sinim returns a sf object", {
42 |
43 | tbl <- get_sinim(c(4333, 4211), 2015, geometry=T)
44 |
45 | expect_is(tbl, c("sf", "data.frame"))
46 | })
47 |
48 | test_that("get_sinim returns a valid output using a region subset", {
49 |
50 | tbl <- get_sinim(c(4333, 4211), 2015, region=1)
51 |
52 | expect_is(tbl, c("data.frame"))
53 | expect_output(str(tbl), "14 obs. of 5 variables")
54 | })
55 |
56 | test_that("get_sinim returns a valid output using a provincia subset", {
57 |
58 | tbl <- get_sinim(c(4333, 4211), 2015, provincia=14)
59 |
60 | expect_is(tbl, c("data.frame"))
61 | expect_output(str(tbl), "10 obs. of 5 variables")
62 | })
63 |
64 | test_that("get_sinim returns a valid output using a comuna subset", {
65 |
66 | tbl <- get_sinim(c(4333, 4211), 2015, comuna=13123)
67 |
68 | expect_is(tbl, c("data.frame"))
69 | expect_output(str(tbl), "2 obs. of 5 variables")
70 | })
71 |
72 | test_that("get_sinim returns a valid output using a AUC subset", {
73 |
74 | tbl <- get_sinim(var=882, year=2018, region = 13, truevalue = T, geometry = T, auc = T, unit = "limites")
75 |
76 | expect_is(tbl, c("data.frame"))
77 | expect_output(str(tbl), "37 obs. of 6 variables")
78 | })
79 |
80 |
--------------------------------------------------------------------------------
/docs/docsearch.js:
--------------------------------------------------------------------------------
1 | $(function() {
2 |
3 | // register a handler to move the focus to the search bar
4 | // upon pressing shift + "/" (i.e. "?")
5 | $(document).on('keydown', function(e) {
6 | if (e.shiftKey && e.keyCode == 191) {
7 | e.preventDefault();
8 | $("#search-input").focus();
9 | }
10 | });
11 |
12 | $(document).ready(function() {
13 | // do keyword highlighting
14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */
15 | var mark = function() {
16 |
17 | var referrer = document.URL ;
18 | var paramKey = "q" ;
19 |
20 | if (referrer.indexOf("?") !== -1) {
21 | var qs = referrer.substr(referrer.indexOf('?') + 1);
22 | var qs_noanchor = qs.split('#')[0];
23 | var qsa = qs_noanchor.split('&');
24 | var keyword = "";
25 |
26 | for (var i = 0; i < qsa.length; i++) {
27 | var currentParam = qsa[i].split('=');
28 |
29 | if (currentParam.length !== 2) {
30 | continue;
31 | }
32 |
33 | if (currentParam[0] == paramKey) {
34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20"));
35 | }
36 | }
37 |
38 | if (keyword !== "") {
39 | $(".contents").unmark({
40 | done: function() {
41 | $(".contents").mark(keyword);
42 | }
43 | });
44 | }
45 | }
46 | };
47 |
48 | mark();
49 | });
50 | });
51 |
52 | /* Search term highlighting ------------------------------*/
53 |
54 | function matchedWords(hit) {
55 | var words = [];
56 |
57 | var hierarchy = hit._highlightResult.hierarchy;
58 | // loop to fetch from lvl0, lvl1, etc.
59 | for (var idx in hierarchy) {
60 | words = words.concat(hierarchy[idx].matchedWords);
61 | }
62 |
63 | var content = hit._highlightResult.content;
64 | if (content) {
65 | words = words.concat(content.matchedWords);
66 | }
67 |
68 | // return unique words
69 | var words_uniq = [...new Set(words)];
70 | return words_uniq;
71 | }
72 |
73 | function updateHitURL(hit) {
74 |
75 | var words = matchedWords(hit);
76 | var url = "";
77 |
78 | if (hit.anchor) {
79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor;
80 | } else {
81 | url = hit.url + '?q=' + escape(words.join(" "));
82 | }
83 |
84 | return url;
85 | }
86 |
--------------------------------------------------------------------------------
/docs/pkgdown.js:
--------------------------------------------------------------------------------
1 | /* http://gregfranko.com/blog/jquery-best-practices/ */
2 | (function($) {
3 | $(function() {
4 |
5 | $('.navbar-fixed-top').headroom();
6 |
7 | $('body').css('padding-top', $('.navbar').height() + 10);
8 | $(window).resize(function(){
9 | $('body').css('padding-top', $('.navbar').height() + 10);
10 | });
11 |
12 | $('[data-toggle="tooltip"]').tooltip();
13 |
14 | var cur_path = paths(location.pathname);
15 | var links = $("#navbar ul li a");
16 | var max_length = -1;
17 | var pos = -1;
18 | for (var i = 0; i < links.length; i++) {
19 | if (links[i].getAttribute("href") === "#")
20 | continue;
21 | // Ignore external links
22 | if (links[i].host !== location.host)
23 | continue;
24 |
25 | var nav_path = paths(links[i].pathname);
26 |
27 | var length = prefix_length(nav_path, cur_path);
28 | if (length > max_length) {
29 | max_length = length;
30 | pos = i;
31 | }
32 | }
33 |
34 | // Add class to parent
, and enclosing if in dropdown
35 | if (pos >= 0) {
36 | var menu_anchor = $(links[pos]);
37 | menu_anchor.parent().addClass("active");
38 | menu_anchor.closest("li.dropdown").addClass("active");
39 | }
40 | });
41 |
42 | function paths(pathname) {
43 | var pieces = pathname.split("/");
44 | pieces.shift(); // always starts with /
45 |
46 | var end = pieces[pieces.length - 1];
47 | if (end === "index.html" || end === "")
48 | pieces.pop();
49 | return(pieces);
50 | }
51 |
52 | // Returns -1 if not found
53 | function prefix_length(needle, haystack) {
54 | if (needle.length > haystack.length)
55 | return(-1);
56 |
57 | // Special case for length-0 haystack, since for loop won't run
58 | if (haystack.length === 0) {
59 | return(needle.length === 0 ? 0 : -1);
60 | }
61 |
62 | for (var i = 0; i < haystack.length; i++) {
63 | if (needle[i] != haystack[i])
64 | return(i);
65 | }
66 |
67 | return(haystack.length);
68 | }
69 |
70 | /* Clipboard --------------------------*/
71 |
72 | function changeTooltipMessage(element, msg) {
73 | var tooltipOriginalTitle=element.getAttribute('data-original-title');
74 | element.setAttribute('data-original-title', msg);
75 | $(element).tooltip('show');
76 | element.setAttribute('data-original-title', tooltipOriginalTitle);
77 | }
78 |
79 | if(ClipboardJS.isSupported()) {
80 | $(document).ready(function() {
81 | var copyButton = " ";
82 |
83 | $("div.sourceCode").addClass("hasCopyButton");
84 |
85 | // Insert copy buttons:
86 | $(copyButton).prependTo(".hasCopyButton");
87 |
88 | // Initialize tooltips:
89 | $('.btn-copy-ex').tooltip({container: 'body'});
90 |
91 | // Initialize clipboard:
92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', {
93 | text: function(trigger) {
94 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, "");
95 | }
96 | });
97 |
98 | clipboardBtnCopies.on('success', function(e) {
99 | changeTooltipMessage(e.trigger, 'Copied!');
100 | e.clearSelection();
101 | });
102 |
103 | clipboardBtnCopies.on('error', function() {
104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy');
105 | });
106 | });
107 | }
108 | })(window.jQuery || window.$)
109 |
--------------------------------------------------------------------------------
/docs/articles/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Articles • sinimR
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 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
65 |
66 |
67 |
90 |
91 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
112 |
113 |
114 |
All vignettes
115 |
116 |
117 |
120 |
121 |
122 |
123 |
124 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/docs/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Page not found (404) • sinimR
9 |
10 |
11 |
12 |
13 |
14 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
66 |
67 |
70 |
71 | Content not found. Please use links in the navbar.
72 |
73 |
74 |
75 |
79 |
80 |
81 |
82 |
83 |
84 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/docs/bootstrap-toc.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/)
3 | * Copyright 2015 Aidan Feldman
4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */
5 | (function() {
6 | 'use strict';
7 |
8 | window.Toc = {
9 | helpers: {
10 | // return all matching elements in the set, or their descendants
11 | findOrFilter: function($el, selector) {
12 | // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/
13 | // http://stackoverflow.com/a/12731439/358804
14 | var $descendants = $el.find(selector);
15 | return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])');
16 | },
17 |
18 | generateUniqueIdBase: function(el) {
19 | var text = $(el).text();
20 | var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-');
21 | return anchor || el.tagName.toLowerCase();
22 | },
23 |
24 | generateUniqueId: function(el) {
25 | var anchorBase = this.generateUniqueIdBase(el);
26 | for (var i = 0; ; i++) {
27 | var anchor = anchorBase;
28 | if (i > 0) {
29 | // add suffix
30 | anchor += '-' + i;
31 | }
32 | // check if ID already exists
33 | if (!document.getElementById(anchor)) {
34 | return anchor;
35 | }
36 | }
37 | },
38 |
39 | generateAnchor: function(el) {
40 | if (el.id) {
41 | return el.id;
42 | } else {
43 | var anchor = this.generateUniqueId(el);
44 | el.id = anchor;
45 | return anchor;
46 | }
47 | },
48 |
49 | createNavList: function() {
50 | return $('');
51 | },
52 |
53 | createChildNavList: function($parent) {
54 | var $childList = this.createNavList();
55 | $parent.append($childList);
56 | return $childList;
57 | },
58 |
59 | generateNavEl: function(anchor, text) {
60 | var $a = $(' ');
61 | $a.attr('href', '#' + anchor);
62 | $a.text(text);
63 | var $li = $(' ');
64 | $li.append($a);
65 | return $li;
66 | },
67 |
68 | generateNavItem: function(headingEl) {
69 | var anchor = this.generateAnchor(headingEl);
70 | var $heading = $(headingEl);
71 | var text = $heading.data('toc-text') || $heading.text();
72 | return this.generateNavEl(anchor, text);
73 | },
74 |
75 | // Find the first heading level (``, then ``, etc.) that has more than one element. Defaults to 1 (for ``).
76 | getTopLevel: function($scope) {
77 | for (var i = 1; i <= 6; i++) {
78 | var $headings = this.findOrFilter($scope, 'h' + i);
79 | if ($headings.length > 1) {
80 | return i;
81 | }
82 | }
83 |
84 | return 1;
85 | },
86 |
87 | // returns the elements for the top level, and the next below it
88 | getHeadings: function($scope, topLevel) {
89 | var topSelector = 'h' + topLevel;
90 |
91 | var secondaryLevel = topLevel + 1;
92 | var secondarySelector = 'h' + secondaryLevel;
93 |
94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector);
95 | },
96 |
97 | getNavLevel: function(el) {
98 | return parseInt(el.tagName.charAt(1), 10);
99 | },
100 |
101 | populateNav: function($topContext, topLevel, $headings) {
102 | var $context = $topContext;
103 | var $prevNav;
104 |
105 | var helpers = this;
106 | $headings.each(function(i, el) {
107 | var $newNav = helpers.generateNavItem(el);
108 | var navLevel = helpers.getNavLevel(el);
109 |
110 | // determine the proper $context
111 | if (navLevel === topLevel) {
112 | // use top level
113 | $context = $topContext;
114 | } else if ($prevNav && $context === $topContext) {
115 | // create a new level of the tree and switch to it
116 | $context = helpers.createChildNavList($prevNav);
117 | } // else use the current $context
118 |
119 | $context.append($newNav);
120 |
121 | $prevNav = $newNav;
122 | });
123 | },
124 |
125 | parseOps: function(arg) {
126 | var opts;
127 | if (arg.jquery) {
128 | opts = {
129 | $nav: arg
130 | };
131 | } else {
132 | opts = arg;
133 | }
134 | opts.$scope = opts.$scope || $(document.body);
135 | return opts;
136 | }
137 | },
138 |
139 | // accepts a jQuery object, or an options object
140 | init: function(opts) {
141 | opts = this.helpers.parseOps(opts);
142 |
143 | // ensure that the data attribute is in place for styling
144 | opts.$nav.attr('data-toggle', 'toc');
145 |
146 | var $topContext = this.helpers.createChildNavList(opts.$nav);
147 | var topLevel = this.helpers.getTopLevel(opts.$scope);
148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel);
149 | this.helpers.populateNav($topContext, topLevel, $headings);
150 | }
151 | };
152 |
153 | $(function() {
154 | $('nav[data-toggle="toc"]').each(function(i, el) {
155 | var $nav = $(el);
156 | Toc.init($nav);
157 | });
158 | });
159 | })();
160 |
--------------------------------------------------------------------------------
/docs/news/index.html:
--------------------------------------------------------------------------------
1 |
2 | Changelog • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
49 |
50 |
51 |
52 |
Fixed and updated GitHub action
53 | Updated site
54 | Added docs for data
55 | Added a NEWS.md file to track changes to the package.
56 |
57 |
58 |
59 |
Fixed error on get_sinim_vars() function
60 |
61 |
62 |
63 |
66 |
67 |
68 |
69 |
70 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/docs/reference/sinimr.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | R library for SINIM — sinimr • sinimR
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 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
115 |
116 |
117 |
Access SINIM data and view it as data frames.
118 |
119 |
120 |
121 |
122 |
123 |
124 |
129 |
130 |
131 |
132 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/docs/authors.html:
--------------------------------------------------------------------------------
1 |
2 | Authors and Citation • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
56 |
62 |
63 |
64 |
Salas R (2025).
65 | sinimr: Chilean Municipalities Information System Wrapper .
66 | R package version 0.3.3, https://github.com/robsalasco/sinimr .
67 |
68 |
@Manual{,
69 | title = {sinimr: Chilean Municipalities Information System Wrapper},
70 | author = {Roberto Salas},
71 | year = {2025},
72 | note = {R package version 0.3.3},
73 | url = {https://github.com/robsalasco/sinimr},
74 | }
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/docs/LICENSE-text.html:
--------------------------------------------------------------------------------
1 |
2 | License • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
48 |
49 |
The MIT License (MIT)
50 |
51 | Copyright (c) 2018 Roberto Salas
52 |
53 | Permission is hereby granted, free of charge, to any person obtaining a copy
54 | of this software and associated documentation files (the "Software"), to deal
55 | in the Software without restriction, including without limitation the rights
56 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
57 | copies of the Software, and to permit persons to whom the Software is
58 | furnished to do so, subject to the following conditions:
59 |
60 | The above copyright notice and this permission notice shall be included in
61 | all copies or substantial portions of the Software.
62 |
63 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
69 | THE SOFTWARE.
70 |
71 |
72 |
73 |
74 |
77 |
78 |
79 |
80 |
81 |
82 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/docs/reference/census_geometry_comunas.html:
--------------------------------------------------------------------------------
1 |
2 | Chilean municipalities polygons as simple features — census_geometry_comunas • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
50 |
51 |
52 |
An sf object containing the chilean municipalities.
53 |
54 |
55 |
58 |
59 |
69 |
73 |
74 |
75 |
78 |
79 |
80 |
81 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/docs/reference/census_geometry_limites.html:
--------------------------------------------------------------------------------
1 |
2 | Chilean municipalities urban boundaries polygons as simple features — census_geometry_limites • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
50 |
51 |
52 |
An sf object containing the chilean municipalities urban boundaries.
53 |
54 |
55 |
58 |
59 |
69 |
73 |
74 |
75 |
78 |
79 |
80 |
81 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/docs/reference/idgeocensus.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Geographical identifier — idgeocensus • sinimR
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 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
69 |
70 |
71 |
94 |
95 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
118 |
119 |
120 |
121 |
A dataset containing the geographical units of the
122 | chilean 2017 census.
123 |
124 |
125 |
126 |
idgeocensus
127 |
128 |
129 |
130 |
A data frame with 246 rows and 6 variables:
131 | CODE.REG Region code
132 | NOM.REG Region name
133 | CODE.PROV Provincia code
134 | NOM.PROV Provincia name
135 | CODE Municipality code
136 | MUNICIPALITY Municipality name
137 |
138 |
139 |
Source
140 |
141 |
http://www.censo2017.cl
142 |
143 |
144 |
145 |
155 |
156 |
157 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
--------------------------------------------------------------------------------
/docs/reference/id_geo_census.html:
--------------------------------------------------------------------------------
1 |
2 | Chilean administrative divisions — id_geo_census • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
50 |
51 |
52 |
A dataset containing the chilean administrative units.
53 |
54 |
55 |
58 |
59 |
84 |
88 |
89 |
90 |
93 |
94 |
95 |
96 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/docs/reference/mm.html:
--------------------------------------------------------------------------------
1 |
2 | Return a abbreviated value of the "miles de millones" format — mm • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
50 |
51 |
52 |
Return a abbreviated value of the "miles de millones" format
53 |
54 |
55 |
58 |
59 |
60 |
Arguments
61 |
62 |
63 |
x
64 | Numeric value to convert
65 |
66 |
67 |
68 |
Value
69 |
A character value in short format
70 |
71 |
72 |
73 |
Examples
74 |
mm ( 5807587000 )
75 | #> [1] "6 mm$"
76 |
77 |
78 |
79 |
82 |
83 |
84 |
85 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/docs/reference/get_sinim_vars.html:
--------------------------------------------------------------------------------
1 |
2 | List available variables for a category — get_sinim_vars • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
50 |
51 |
52 |
List available variables for a category
53 |
54 |
55 |
58 |
59 |
60 |
Arguments
61 |
62 |
63 |
catn
64 | category number
65 |
66 |
67 |
68 |
Value
69 |
data frame with variables and values
70 |
71 |
72 |
73 |
Examples
74 |
get_sinim_vars ( 47 )
75 | #> variable unit code
76 | #> 1 Indice de Pobreza CASEN (Última Encuesta Vigente) % 744
77 |
78 |
79 |
80 |
83 |
84 |
85 |
86 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/docs/reference/getsinimvariables.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | List available variables for a category — getsinimvariables • sinimR
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 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
68 |
69 |
70 |
93 |
94 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
117 |
118 |
119 |
120 |
List available variables for a category
121 |
122 |
123 |
124 |
getsinimvariables (catn )
125 |
126 |
Arguments
127 |
128 |
129 |
130 | catn
131 | category number
132 |
133 |
134 |
135 |
Value
136 |
137 |
data frame with variables and values
138 |
139 |
140 |
Examples
141 |
getsinimvariables (47 )
#> VARIABLE UNIT CODE
142 | #> 314 Porcentaje de Población en Condiciones de Pobreza , según CASEN % 562
143 | #> 315 Indice de Pobreza CASEN (Última Encuesta Vigente) % 744
144 |
145 |
156 |
157 |
158 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
--------------------------------------------------------------------------------
/docs/reference/get_sinim_var_name.html:
--------------------------------------------------------------------------------
1 |
2 | Return SINIM variable name using their internal codes — get_sinim_var_name • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
50 |
51 |
52 |
Return SINIM variable name using their internal codes
53 |
54 |
55 |
58 |
59 |
60 |
Arguments
61 |
62 |
63 |
var
64 | Variable code
65 |
66 |
67 |
68 |
Value
69 |
A vector of requested variable names
70 |
71 |
72 |
73 |
Examples
74 |
get_sinim_var_name ( 880 )
75 | #> [1] "INGRESOS POR FONDO COMÚN MUNICIPAL"
76 | get_sinim_var_name ( c ( 880 , 882 ) )
77 | #> [1] "INGRESOS POR FONDO COMÚN MUNICIPAL" "INGRESOS PROPIOS (IPP Y FCM)"
78 |
79 |
80 |
81 |
84 |
85 |
86 |
87 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/docs/reference/index.html:
--------------------------------------------------------------------------------
1 |
2 | Package index • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
48 |
49 |
50 | All functions
51 |
52 |
53 |
54 | census_geometry_comunas
55 |
56 | Chilean municipalities polygons as simple features
57 |
58 | census_geometry_limites
59 |
60 | Chilean municipalities urban boundaries polygons as simple features
61 |
62 | get_sinim()
63 |
64 | Get a SINIM variable data in a specific year as a data frame
65 |
66 | get_sinim_cats()
67 |
68 | Get SINIM data categories
69 |
70 | get_sinim_var_name()
71 |
72 | Return SINIM variable name using their internal codes
73 |
74 | get_sinim_vars()
75 |
76 | List available variables for a category
77 |
78 | id_geo_census
79 |
80 | Chilean administrative divisions
81 |
82 | mm()
83 |
84 | Return a abbreviated value of the "miles de millones" format
85 |
86 | search_sinim_vars()
87 |
88 | Search for a SINIM variable and if no keyword is provided returns all variables
89 |
90 |
91 |
94 |
95 |
96 |
97 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/R/helpers.R:
--------------------------------------------------------------------------------
1 | #' @import httr
2 | #' @import XML
3 | #' @importFrom jsonlite fromJSON
4 | #' @importFrom reshape2 melt
5 | #' @importFrom stats complete.cases
6 |
7 | # Helper functions for API calls, data parsing, and variable lookups used throughout the sinimr package.
8 |
9 | # Register global variables to avoid CRAN NOTES about undefined variables in data manipulation code.
10 | utils::globalVariables(c(
11 | "id_geo_census", "code.reg", "code.prov", "code",
12 | "census_geometry_comunas", "census_geometry_limites", "id_subarea"
13 | ))
14 |
15 | # Call the SINIM API with a GET request and return the raw response as a string.
16 | callapi <- function(url) { # nocov start
17 | resp <- httr::GET(url, add_headers("X-Request-Source" = "r"))
18 | stop_for_status(resp, task = "call api")
19 | data <- httr::content(resp, "text", encoding = "UTF-8")
20 | data <- substr(data, 2, nchar(data))
21 |
22 | return(data)
23 | } # nocov end
24 |
25 | # Call the SINIM API with a POST request and return the parsed JSON response.
26 | postapi <- function(url, body) { # nocov start
27 | resp <- httr::POST(
28 | url,
29 | body = body,
30 | add_headers(
31 | "User-Agent" = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15",
32 | "Referer" = "https://datos.sinim.gov.cl/datos_municipales.php",
33 | "Host" = "datos.sinim.gov.cl",
34 | "X-Requested-With" = "XMLHttpRequest",
35 | "Accept-Encoding" = "gzip, deflate, br"
36 | )
37 | )
38 |
39 | stop_for_status(resp, task = "call api")
40 |
41 | data <- jsonlite::fromJSON(content(resp, "text"))
42 | return(data)
43 | } # nocov end
44 |
45 | # Validate and convert a year or vector of years to their index in the supported year list.
46 | getyear <- function(year) { # nocov start
47 | year_list <- c(
48 | 2000,
49 | 2001,
50 | 2002,
51 | 2003,
52 | 2004,
53 | 2005,
54 | 2006,
55 | 2007,
56 | 2008,
57 | 2009,
58 | 2010,
59 | 2011,
60 | 2012,
61 | 2013,
62 | 2014,
63 | 2015,
64 | 2016,
65 | 2017,
66 | 2018,
67 | 2019,
68 | 2020,
69 | 2021,
70 | 2022,
71 | 2023,
72 | 2024
73 | )
74 | if (any(is.na(match(year, year_list)))) {
75 | stop("Year not found in list")
76 | } else {
77 | return(match(year, year_list))
78 | }
79 | } # nocov end
80 |
81 | # Retrieve the internal SINIM variable ID(s) for a given variable name or names.
82 | getid <- function(name) { # nocov start
83 | body <- list("dato_area[]" = "T", "dato_subarea[]" = "T")
84 | resp <-
85 | postapi(
86 | "https://datos.sinim.gov.cl/datos_municipales/obtener_datos_filtros.php",
87 | body
88 | )
89 | list <- reshape2::melt(sapply(resp, function(b)
90 | b$mtro_datos_nombre))
91 | values <- reshape2::melt(sapply(resp, function(b)
92 | b$id_dato))
93 | list$id <- values$value
94 | colnames(list) <- c("variable", "category", "value")
95 | list$variable <-
96 | as.vector(lapply(as.character(list$variable), function(x)
97 | trimws(x)))
98 | return(list[complete.cases(match(list$variable, name)), 3])
99 | } # nocov end
100 |
101 | # Retrieve the SINIM variable name(s) for a given variable code or codes.
102 | getname <- function(names) { # nocov start
103 | body <- list("dato_area[]" = "T", "dato_subarea[]" = "T")
104 | resp <- postapi(
105 | "https://datos.sinim.gov.cl/datos_municipales/obtener_datos_filtros.php",
106 | body
107 | )
108 | list <- reshape2::melt(sapply(resp, function(b)
109 | b$mtro_datos_nombre))
110 | values <- reshape2::melt(sapply(resp, function(b)
111 | b$id_dato))
112 | list$id <- values$value
113 | colnames(list) <- c("variable", "category", "value")
114 | list$variable <-
115 | as.vector(lapply(as.character(list$variable), function(x)
116 | trimws(x)))
117 | names.list <- gsub("\\.", "", toupper(unlist(list[which(list$value %in% names), 1])))
118 | return(names.list)
119 | } # nocov end
120 |
121 | # Parse XML data from the SINIM API for the given variables and years, optionally applying monetary correction.
122 | parsexml <- function(var, years, moncorr=T) { # nocov start
123 | yearsn <- getyear(years)
124 | if(moncorr==T){
125 | url <- paste(
126 | "https://datos.sinim.gov.cl/datos_municipales/obtener_datos_municipales.php?area[]=T&subarea[]=T&variables[]=",
127 | paste(var, collapse = ","), "&periodos[]=", paste(yearsn, collapse = ","), "®iones[]=T&municipios[]=T&corrmon=1",
128 | sep = ""
129 | )
130 | } else {
131 | url <- paste(
132 | "https://datos.sinim.gov.cl/datos_municipales/obtener_datos_municipales.php?area[]=T&subarea[]=T&variables[]=",
133 | paste(var, collapse = ","), "&periodos[]=", paste(yearsn, collapse = ","), "®iones[]=T&municipios[]=T&corrmon=0",
134 | sep = ""
135 | )
136 | }
137 | data <- XML::xmlParse(callapi(url))
138 | columns <- as.numeric(
139 | XML::xpathApply(
140 | data,
141 | "//tei:Table/@tei:ExpandedColumnCount",
142 | namespaces = c(tei = getDefaultNamespace(data)[[1]]$uri)
143 | )[[1]][[1]],
144 | xmlValue
145 | )
146 | varxml <- XML::xpathSApply(
147 | data,
148 | "//tei:Cell[not(@tei:StyleID)]",
149 | namespaces = c(tei = getDefaultNamespace(data)[[1]]$uri),
150 | xmlValue
151 | )
152 | values <- matrix(varxml,
153 | nrow = length(varxml)/((length(var)*length(yearsn))+2),
154 | ncol = ((length(var)*length(yearsn))+2), byrow = T)
155 | values <- as.data.frame(values, stringsAsFactors = F)
156 | return(values)
157 | } # nocov end
158 |
159 | # Construct column names for variables and years in the format VARIABLE.YEAR.
160 | namesco <- function(x,y){ #nocov start
161 | rep_vars <- rep(getname(x), each=length(y))
162 | rep_years <- rep(sort(y, decreasing = T), length(x))
163 | return(paste(rep_vars, rep_years, sep="."))
164 | } # nocov end
165 |
166 | # Filter geographic codes by region, province, or comuna, with optional AUC filtering.
167 | geofilter <- function(region, provincia, comuna, auc=F) { #nocov start
168 | if (!missing(region)) {
169 | stopifnot(missing(provincia))
170 | stopifnot(missing(comuna))
171 | if(auc==T) {
172 | selection <- subset(id_geo_census, code.reg %in% region &
173 | auc==1)$code
174 | } else {
175 | selection <- subset(id_geo_census, code.reg %in% region)$code
176 | }
177 | return(selection)
178 | } else if (!missing(provincia)) {
179 | stopifnot(missing(region))
180 | stopifnot(missing(comuna))
181 | if(auc==T) {
182 | warning("AUC not available subsetting provincias")
183 | }
184 | selection <- subset(id_geo_census, code.prov %in% provincia)$code
185 | return(selection)
186 | } else if (!missing(comuna)) {
187 | stopifnot(missing(region))
188 | stopifnot(missing(provincia))
189 | if(auc==T) {
190 | warning("AUC not available subsetting comunas")
191 | }
192 | selection <- subset(id_geo_census, code %in% comuna)$code
193 | return(selection)
194 | } else {
195 | return(id_geo_census$code)
196 | }
197 | } # nocov end
198 |
--------------------------------------------------------------------------------
/R/get_sinim.R:
--------------------------------------------------------------------------------
1 | #' Get a SINIM variable data in a specific year as a data frame
2 | #' @param var Variable code
3 | #' @param year Year
4 | #' @param moncorr A logical value indicating the use of monetary correction
5 | #' @param truevalue A logical value indicating the use of converted values
6 | #' @param idgeo A logical value to add provincia and region columns
7 | #' @param geometry A logical value to add geographical features
8 | #' @param region Region subsetting variable
9 | #' @param provincia Provincia subsetting variable
10 | #' @param comuna Comuna subsetting variable
11 | #' @param auc A logical value to retrieve only AUC features
12 | #' @param unit Use "comunas" or "limites"
13 | #' @return data frame for the requested variable over time with optional geometry
14 | #' @export
15 | #' @examples
16 | #' get_sinim(880, 2015)
17 | #' get_sinim(880, 2015:2017)
18 | #' get_sinim(c(880, 882), 2015)
19 | #' get_sinim(c(880, 882), 2015:2017)
20 | #' get_sinim(c(880, 882), 2015, idgeo=TRUE)
21 | #' get_sinim(882, 2015, geometry=TRUE)
22 | #' get_sinim(882, 2015, region="02")
23 | #' @importFrom reshape2 melt
24 | #' @importFrom stats reshape
25 | #' @importFrom stats na.omit
26 | #' @import sf
27 | #'
28 | get_sinim <-
29 | function(var,
30 | year,
31 | moncorr = T,
32 | truevalue = F,
33 | idgeo = F,
34 | geometry = F,
35 | region,
36 | provincia,
37 | comuna,
38 | auc = F,
39 | unit = "comunas") {
40 | stopifnot(is.numeric(var))
41 | stopifnot(is.numeric(year))
42 |
43 | # Download and parse the raw data for the requested variables and years
44 | values <- parsexml(var, year, moncorr = moncorr)
45 |
46 | # Set column names for the parsed data
47 | colnames(values) <-
48 | c("code", "municipality", namesco(var, year))
49 |
50 | # Reshape the data to long format for easier manipulation
51 | datav <- stats::reshape(
52 | values,
53 | idvar = c("code", "municipality"),
54 | varying = namesco(var, year),
55 | direction = "long",
56 | timevar = "year",
57 | times = sort(year, decreasing = T)
58 | )
59 |
60 | # Remove row names for clarity
61 | rownames(datav) <- NULL
62 |
63 | # Replace 'No Recepcionado' and 'No Aplica' with NA
64 | datav <-
65 | as.data.frame(apply(datav, 2, function(x)
66 | gsub("No Recepcionado|No Aplica", NA, x)), stringsAsFactors = FALSE)
67 |
68 | if (geometry == FALSE) {
69 | # Melt the data to have one row per variable per year
70 | datav <- reshape2::melt(
71 | datav,
72 | id = c("code", "municipality", "year"),
73 | value.name = "value",
74 | variable.name = "variable"
75 | )
76 |
77 | datav$variable <- as.character(datav$variable)
78 |
79 | # Identify numeric columns for conversion
80 | t <-
81 | vapply(datav, function(x)
82 | all(grepl("[0-9]+", na.omit(x))), logical(1))
83 |
84 | t[1:4] <- c(TRUE, FALSE, FALSE, FALSE)
85 | datav[t] <- lapply(datav[t], function(x)
86 | (as.numeric(x)))
87 |
88 | # Apply value conversion if requested
89 | if (truevalue == TRUE) {
90 | datav$value <- datav$value * 1000
91 | }
92 |
93 | # Subset by region, provincia, or comuna if provided
94 | if (!missing(region) |
95 | !missing(provincia) |
96 | !missing(comuna)) {
97 | selection <-
98 | geofilter(region = region,
99 | provincia = provincia,
100 | comuna = comuna,
101 | auc)
102 | data.selection <- subset(datav, code %in% selection)
103 |
104 | # Merge with geographic info if requested
105 | if (idgeo == T) {
106 | merged.pretty <-
107 | merge(data.selection,
108 | id_geo_census,
109 | by = c("code", "municipality"))
110 | return(merged.pretty)
111 | } else {
112 | return(data.selection)
113 | }
114 |
115 | } else {
116 | # Merge with geographic info for all data if requested
117 | if (idgeo == T) {
118 | merged.pretty <- merge(datav, id_geo_census, by = "code")
119 | return(merged.pretty)
120 | } else {
121 | return(datav)
122 | }
123 | }
124 | } else {
125 | # Melt the data for geometry output
126 | datav <- reshape2::melt(
127 | datav,
128 | id = c("code", "municipality", "year"),
129 | value.name = "value",
130 | variable.name = "variable"
131 | )
132 |
133 | datav$variable <- as.character(datav$variable)
134 |
135 | # Identify numeric columns for conversion
136 | t <-
137 | vapply(datav, function(x)
138 | all(grepl("[0-9]+", na.omit(x))), logical(1))
139 |
140 | t[1:4] <- c(TRUE, FALSE, FALSE, FALSE)
141 | datav[t] <- lapply(datav[t], function(x)
142 | (as.numeric(x)))
143 |
144 | # Apply value conversion if requested
145 | if (truevalue == TRUE) {
146 | datav$value <- datav$value * 1000
147 | }
148 |
149 | # Subset by region, provincia, or comuna if provided
150 | if (!missing(region) |
151 | !missing(provincia) |
152 | !missing(comuna)) {
153 | selection <-
154 | geofilter(region = region,
155 | provincia = provincia,
156 | comuna = comuna,
157 | auc)
158 |
159 | data.selection <- subset(datav, code %in% selection)
160 |
161 | # Merge with geometry based on the selected unit
162 | if (unit == "comunas") {
163 | merged.geo <-
164 | merge(census_geometry_comunas, data.selection, by = "code")
165 | } else if (unit == "limites") {
166 | merged.geo <-
167 | merge(census_geometry_limites, data.selection, by = "code")
168 | } else {
169 | stop("Unit not valid")
170 | }
171 |
172 | # Merge with geographic info if requested
173 | if (idgeo == T) {
174 | merged.geo.pretty <-
175 | merge(merged.geo,
176 | id_geo_census,
177 | by = c("code", "municipality"))
178 | return(merged.geo.pretty)
179 | } else {
180 | return(merged.geo)
181 | }
182 |
183 | } else {
184 | # Merge with geometry for all data based on the selected unit
185 | if (unit == "comunas") {
186 | merged.geo <-
187 | merge(census_geometry_comunas, datav, by = "code")
188 | } else if (unit == "limites") {
189 | merged.geo <-
190 | merge(census_geometry_limites, datav, by = "code")
191 | } else {
192 | stop("Unit not valid")
193 | }
194 |
195 | # Merge with geographic info if requested
196 | if (idgeo == T) {
197 | merged.geo.pretty <- merge(merged.geo, id_geo_census, by = c("code","municipality"))
198 | return(merged.geo.pretty)
199 | } else {
200 | return(merged.geo)
201 | }
202 | }
203 | }
204 | }
205 |
--------------------------------------------------------------------------------
/docs/pkgdown.css:
--------------------------------------------------------------------------------
1 | /* Sticky footer */
2 |
3 | /**
4 | * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/
5 | * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css
6 | *
7 | * .Site -> body > .container
8 | * .Site-content -> body > .container .row
9 | * .footer -> footer
10 | *
11 | * Key idea seems to be to ensure that .container and __all its parents__
12 | * have height set to 100%
13 | *
14 | */
15 |
16 | html, body {
17 | height: 100%;
18 | }
19 |
20 | body {
21 | position: relative;
22 | }
23 |
24 | body > .container {
25 | display: flex;
26 | height: 100%;
27 | flex-direction: column;
28 | }
29 |
30 | body > .container .row {
31 | flex: 1 0 auto;
32 | }
33 |
34 | footer {
35 | margin-top: 45px;
36 | padding: 35px 0 36px;
37 | border-top: 1px solid #e5e5e5;
38 | color: #666;
39 | display: flex;
40 | flex-shrink: 0;
41 | }
42 | footer p {
43 | margin-bottom: 0;
44 | }
45 | footer div {
46 | flex: 1;
47 | }
48 | footer .pkgdown {
49 | text-align: right;
50 | }
51 | footer p {
52 | margin-bottom: 0;
53 | }
54 |
55 | img.icon {
56 | float: right;
57 | }
58 |
59 | /* Ensure in-page images don't run outside their container */
60 | .contents img {
61 | max-width: 100%;
62 | height: auto;
63 | }
64 |
65 | /* Fix bug in bootstrap (only seen in firefox) */
66 | summary {
67 | display: list-item;
68 | }
69 |
70 | /* Typographic tweaking ---------------------------------*/
71 |
72 | .contents .page-header {
73 | margin-top: calc(-60px + 1em);
74 | }
75 |
76 | dd {
77 | margin-left: 3em;
78 | }
79 |
80 | /* Section anchors ---------------------------------*/
81 |
82 | a.anchor {
83 | display: none;
84 | margin-left: 5px;
85 | width: 20px;
86 | height: 20px;
87 |
88 | background-image: url(./link.svg);
89 | background-repeat: no-repeat;
90 | background-size: 20px 20px;
91 | background-position: center center;
92 | }
93 |
94 | h1:hover .anchor,
95 | h2:hover .anchor,
96 | h3:hover .anchor,
97 | h4:hover .anchor,
98 | h5:hover .anchor,
99 | h6:hover .anchor {
100 | display: inline-block;
101 | }
102 |
103 | /* Fixes for fixed navbar --------------------------*/
104 |
105 | .contents h1, .contents h2, .contents h3, .contents h4 {
106 | padding-top: 60px;
107 | margin-top: -40px;
108 | }
109 |
110 | /* Navbar submenu --------------------------*/
111 |
112 | .dropdown-submenu {
113 | position: relative;
114 | }
115 |
116 | .dropdown-submenu>.dropdown-menu {
117 | top: 0;
118 | left: 100%;
119 | margin-top: -6px;
120 | margin-left: -1px;
121 | border-radius: 0 6px 6px 6px;
122 | }
123 |
124 | .dropdown-submenu:hover>.dropdown-menu {
125 | display: block;
126 | }
127 |
128 | .dropdown-submenu>a:after {
129 | display: block;
130 | content: " ";
131 | float: right;
132 | width: 0;
133 | height: 0;
134 | border-color: transparent;
135 | border-style: solid;
136 | border-width: 5px 0 5px 5px;
137 | border-left-color: #cccccc;
138 | margin-top: 5px;
139 | margin-right: -10px;
140 | }
141 |
142 | .dropdown-submenu:hover>a:after {
143 | border-left-color: #ffffff;
144 | }
145 |
146 | .dropdown-submenu.pull-left {
147 | float: none;
148 | }
149 |
150 | .dropdown-submenu.pull-left>.dropdown-menu {
151 | left: -100%;
152 | margin-left: 10px;
153 | border-radius: 6px 0 6px 6px;
154 | }
155 |
156 | /* Sidebar --------------------------*/
157 |
158 | #pkgdown-sidebar {
159 | margin-top: 30px;
160 | position: -webkit-sticky;
161 | position: sticky;
162 | top: 70px;
163 | }
164 |
165 | #pkgdown-sidebar h2 {
166 | font-size: 1.5em;
167 | margin-top: 1em;
168 | }
169 |
170 | #pkgdown-sidebar h2:first-child {
171 | margin-top: 0;
172 | }
173 |
174 | #pkgdown-sidebar .list-unstyled li {
175 | margin-bottom: 0.5em;
176 | }
177 |
178 | /* bootstrap-toc tweaks ------------------------------------------------------*/
179 |
180 | /* All levels of nav */
181 |
182 | nav[data-toggle='toc'] .nav > li > a {
183 | padding: 4px 20px 4px 6px;
184 | font-size: 1.5rem;
185 | font-weight: 400;
186 | color: inherit;
187 | }
188 |
189 | nav[data-toggle='toc'] .nav > li > a:hover,
190 | nav[data-toggle='toc'] .nav > li > a:focus {
191 | padding-left: 5px;
192 | color: inherit;
193 | border-left: 1px solid #878787;
194 | }
195 |
196 | nav[data-toggle='toc'] .nav > .active > a,
197 | nav[data-toggle='toc'] .nav > .active:hover > a,
198 | nav[data-toggle='toc'] .nav > .active:focus > a {
199 | padding-left: 5px;
200 | font-size: 1.5rem;
201 | font-weight: 400;
202 | color: inherit;
203 | border-left: 2px solid #878787;
204 | }
205 |
206 | /* Nav: second level (shown on .active) */
207 |
208 | nav[data-toggle='toc'] .nav .nav {
209 | display: none; /* Hide by default, but at >768px, show it */
210 | padding-bottom: 10px;
211 | }
212 |
213 | nav[data-toggle='toc'] .nav .nav > li > a {
214 | padding-left: 16px;
215 | font-size: 1.35rem;
216 | }
217 |
218 | nav[data-toggle='toc'] .nav .nav > li > a:hover,
219 | nav[data-toggle='toc'] .nav .nav > li > a:focus {
220 | padding-left: 15px;
221 | }
222 |
223 | nav[data-toggle='toc'] .nav .nav > .active > a,
224 | nav[data-toggle='toc'] .nav .nav > .active:hover > a,
225 | nav[data-toggle='toc'] .nav .nav > .active:focus > a {
226 | padding-left: 15px;
227 | font-weight: 500;
228 | font-size: 1.35rem;
229 | }
230 |
231 | /* orcid ------------------------------------------------------------------- */
232 |
233 | .orcid {
234 | font-size: 16px;
235 | color: #A6CE39;
236 | /* margins are required by official ORCID trademark and display guidelines */
237 | margin-left:4px;
238 | margin-right:4px;
239 | vertical-align: middle;
240 | }
241 |
242 | /* Reference index & topics ----------------------------------------------- */
243 |
244 | .ref-index th {font-weight: normal;}
245 |
246 | .ref-index td {vertical-align: top; min-width: 100px}
247 | .ref-index .icon {width: 40px;}
248 | .ref-index .alias {width: 40%;}
249 | .ref-index-icons .alias {width: calc(40% - 40px);}
250 | .ref-index .title {width: 60%;}
251 |
252 | .ref-arguments th {text-align: right; padding-right: 10px;}
253 | .ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px}
254 | .ref-arguments .name {width: 20%;}
255 | .ref-arguments .desc {width: 80%;}
256 |
257 | /* Nice scrolling for wide elements --------------------------------------- */
258 |
259 | table {
260 | display: block;
261 | overflow: auto;
262 | }
263 |
264 | /* Syntax highlighting ---------------------------------------------------- */
265 |
266 | pre, code, pre code {
267 | background-color: #f8f8f8;
268 | color: #333;
269 | }
270 | pre, pre code {
271 | white-space: pre-wrap;
272 | word-break: break-all;
273 | overflow-wrap: break-word;
274 | }
275 |
276 | pre {
277 | border: 1px solid #eee;
278 | }
279 |
280 | pre .img, pre .r-plt {
281 | margin: 5px 0;
282 | }
283 |
284 | pre .img img, pre .r-plt img {
285 | background-color: #fff;
286 | }
287 |
288 | code a, pre a {
289 | color: #375f84;
290 | }
291 |
292 | a.sourceLine:hover {
293 | text-decoration: none;
294 | }
295 |
296 | .fl {color: #1514b5;}
297 | .fu {color: #000000;} /* function */
298 | .ch,.st {color: #036a07;} /* string */
299 | .kw {color: #264D66;} /* keyword */
300 | .co {color: #888888;} /* comment */
301 |
302 | .error {font-weight: bolder;}
303 | .warning {font-weight: bolder;}
304 |
305 | /* Clipboard --------------------------*/
306 |
307 | .hasCopyButton {
308 | position: relative;
309 | }
310 |
311 | .btn-copy-ex {
312 | position: absolute;
313 | right: 0;
314 | top: 0;
315 | visibility: hidden;
316 | }
317 |
318 | .hasCopyButton:hover button.btn-copy-ex {
319 | visibility: visible;
320 | }
321 |
322 | /* headroom.js ------------------------ */
323 |
324 | .headroom {
325 | will-change: transform;
326 | transition: transform 200ms linear;
327 | }
328 | .headroom--pinned {
329 | transform: translateY(0%);
330 | }
331 | .headroom--unpinned {
332 | transform: translateY(-100%);
333 | }
334 |
335 | /* mark.js ----------------------------*/
336 |
337 | mark {
338 | background-color: rgba(255, 255, 51, 0.5);
339 | border-bottom: 2px solid rgba(255, 153, 51, 0.3);
340 | padding: 1px;
341 | }
342 |
343 | /* vertical spacing after htmlwidgets */
344 | .html-widget {
345 | margin-bottom: 10px;
346 | }
347 |
348 | /* fontawesome ------------------------ */
349 |
350 | .fab {
351 | font-family: "Font Awesome 5 Brands" !important;
352 | }
353 |
354 | /* don't display links in code chunks when printing */
355 | /* source: https://stackoverflow.com/a/10781533 */
356 | @media print {
357 | code a:link:after, code a:visited:after {
358 | content: "";
359 | }
360 | }
361 |
362 | /* Section anchors ---------------------------------
363 | Added in pandoc 2.11: https://github.com/jgm/pandoc-templates/commit/9904bf71
364 | */
365 |
366 | div.csl-bib-body { }
367 | div.csl-entry {
368 | clear: both;
369 | }
370 | .hanging-indent div.csl-entry {
371 | margin-left:2em;
372 | text-indent:-2em;
373 | }
374 | div.csl-left-margin {
375 | min-width:2em;
376 | float:left;
377 | }
378 | div.csl-right-inline {
379 | margin-left:2em;
380 | padding-left:1em;
381 | }
382 | div.csl-indent {
383 | margin-left: 2em;
384 | }
385 |
--------------------------------------------------------------------------------
/docs/reference/getsinimcategories.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Get SINIM data categories — getsinimcategories • sinimR
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 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
68 |
69 |
70 |
93 |
94 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
117 |
118 |
119 |
120 |
Get SINIM data categories
121 |
122 |
123 |
124 |
getsinimcategories ()
125 |
126 |
Value
127 |
128 |
Returns a data frame with available data in SINIM's webpage
129 |
130 |
131 |
Examples
132 |
getsinimcategories ()
#> $`-`
133 | #> VARIABLE CODE
134 | #> 1 * SIM FIMU 539
135 | #>
136 | #> $`01. ADMINISTRACION Y FINANZAS MUNICIPALES`
137 | #> VARIABLE CODE
138 | #> 1 A.1. PRESUPUESTO INICIAL Y VIGENTE MUNICIPAL (M$) 517
139 | #> 2 A. INGRESOS MUNICIPALES (M$) 21
140 | #> 3 B. INGRESOS MUNICIPALES (%) 191
141 | #> 4 C. GASTOS MUNICIPALES (M$) 22
142 | #> 5 D. GASTOS MUNICIPALES (%) 172
143 | #> 6 E. GASTOS EN PERSONAL 169
144 | #> 7 F. TRANSFERENCIAS E INVERSION 170
145 | #> 8 G. SERVICIOS BASICOS Y GENERALES 370
146 | #> 9 I. TRANSFERENCIAS Y COMPENSACIONES SUBDERE 485
147 | #> 10 J. FONDO COMÚN MUNICIPAL (FCM) 508
148 | #> 11 K. GESTION MUNICIPAL 486
149 | #> 12 L. 24
150 | #> 13 M. 506
151 | #>
152 | #> $`02. RECURSOS HUMANOS MUNICIPAL`
153 | #> VARIABLE CODE
154 | #> 1 A. PERSONAL DE PLANTA 381
155 | #> 2 B. PERSONAL A CONTRATA 382
156 | #> 3 C. HONORARIOS 383
157 | #> 4 D. CÓDIGO DEL TRABAJO 523
158 | #> 5 D. OTROS INDICADORES 384
159 | #>
160 | #> $`03. EDUCACION MUNICIPAL`
161 | #> VARIABLE CODE
162 | #> 1 A. ANTECEDENTES GENERALES DE EDUCACION 38
163 | #> 2 B. ASISTENCIA Y MATRÍCULAS EN EDUCACION 32
164 | #> 3 C. RESULTADOS PSU 33
165 | #> 4 D. INGRESOS EN EDUCACION MUNICIPAL 35
166 | #> 5 E. GASTOS EN EDUCACION MUNICIPAL 36
167 | #> 6 F. RECURSOS HUMANOS EN SECTOR EDUCACION 34
168 | #> 7 G. ESTABLECIMIENTOS DE EDUCACION MUNICIPAL 379
169 | #>
170 | #> $`04. SALUD MUNICIPAL`
171 | #> VARIABLE CODE
172 | #> 1 A. ANTECEDENTES GENERALES DE SALUD 30
173 | #> 2 B. COBERTURA EN SALUD MUNICIPAL 25
174 | #> 3 C. INGRESOS EN SALUD MUNICIPAL 26
175 | #> 4 D. GASTOS EN SALUD MUNICIPAL 28
176 | #> 5 E. RED ASISTENCIAL SALUD 31
177 | #> 6 F. RECURSOS HUMANOS EN SALUD 362
178 | #>
179 | #> $`05. SOCIAL Y COMUNITARIA`
180 | #> VARIABLE CODE
181 | #> 1 A. INFORMACION ENCUESTA CASEN 47
182 | #> 2 B. RED SOCIAL (SUBSIDIOS Y PENSIONES) 44
183 | #> 3 C. INTERMEDIACION LABORAL 43
184 | #> 4 D. ORGANIZACIONES COMUNITARIAS 46
185 | #> 5 E. BECAS 377
186 | #> 6 F. PARTICIPACIÓN CIUDADANA 510
187 | #> 7 G. DISCAPACIDAD 512
188 | #> 8 H. PREVENCIÓN DEL DELITO 511
189 | #>
190 | #> $`06. DESARROLLO Y GESTION TERRITORIAL`
191 | #> VARIABLE CODE
192 | #> 1 A. CARACTERISTICAS TERRITORIALES 39
193 | #> 2 B. SERVICIOS BASICOS A LA COMUNIDAD 41
194 | #> 3 C. INFRAESTRUCTURA 40
195 | #> 4 D. CATASTRO PREDIOS Y VALORACION CATASTRAL 300
196 | #> 5 E. AREAS VERDES 376
197 | #> 6 F. PLAN DE DESARROLLO COMUNAL (PLADECO) 304
198 | #> 7 G. PLAN REGULADOR COMUNAL 42
199 | #>
200 | #> $`07. CARACTERIZACION COMUNAL`
201 | #> VARIABLE CODE
202 | #> 1 A. GEOGRAFICO ADMINISTRATIVA 49
203 | #> 2 B. POBLACION 50
204 | #>
205 | #> $`08. GENERO`
206 | #> VARIABLE CODE
207 | #> 1 A. DOTACION FUNCIONARIA Y PROFESIONAL DE MUJERES 262
208 | #>
209 | #> $`09. CEMENTERIO`
210 | #> VARIABLE CODE
211 | #> 1 1. INFORMACION GENERAL 516
212 | #> 2 A. INGRESOS CEMENTERIO (M$) 456
213 | #> 3 B. GASTOS CEMENTERIO (M$) 457
214 | #>
215 |
216 |
226 |
227 |
228 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
--------------------------------------------------------------------------------
/README.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | output: github_document
3 | ---
4 |
5 | ```{r, echo = FALSE}
6 | knitr::opts_chunk$set(
7 | collapse = TRUE,
8 | comment = "#>",
9 | fig.path = "man/figures/"
10 | )
11 | ```
12 |
13 | [](https://saythanks.io/to/robsalasco)
14 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=WDDLRUVD344XL¤cy_code=USD&source=url)
15 | [](https://github.com/robsalasco/sinimr/actions)
16 | [](https://app.codecov.io/github/robsalasco/sinimr?branch=master)
17 |
18 | # sinimR
19 |
20 | Chilean Municipalities Information System Wrapper
21 |
22 | ### What can I do with this?
23 |
24 | This R package allows easy SINIM (https://sinim.gov.cl) data retrieval what have advantages over the site:
25 |
26 | - When you work with multiple variables or years it will be very useful for rapid analyses.
27 | - Fast ploting directly from data source using the included geometries.
28 | - Data download with or without monetary correction using a switch.
29 |
30 | ```{r, message=F, fig.height=6, fig.width=6, fig.retina=2}
31 | library(dplyr)
32 | library(sinimr)
33 | library(sf)
34 | library(tmap)
35 |
36 | varcode <- 882
37 | var <- get_sinim(varcode, 2018,
38 | region = 13,
39 | truevalue = T,
40 | geometry = T,
41 | auc = T,
42 | unit = "limites")
43 |
44 | gran_santiago_plot <- tm_shape(var) +
45 | tm_fill(col = "value",
46 | palette = "BuPu",
47 | border.col = "white",
48 | border.alpha = 0.5,
49 | lwd=1,
50 | style = "jenks",
51 | title = get_sinim_var_name(varcode))+
52 | tm_text("municipality", size = 0.4, style="jenks") +
53 | tm_legend(legend.position = c("left", "top"), legend.title.size = 1, legend.text.size = 0.6) +
54 | tm_compass(type = "8star", position = c(.85, .80)) +
55 | tm_scale_bar(breaks = c(0, 10), text.size = 0.75, position = c("right", "bottom")) +
56 | tm_credits("Fuente: Sistema Nacional de Información Municipal (SINIM), SUBDERE, Ministerio del Interior.", position=c("left", "bottom"), size=0.55)+
57 | tm_layout(legend.width=1,
58 | inner.margins = c(0.1, 0.1, 0.10, 0.1),
59 | legend.format = list(text.separator = "a",
60 | fun = mm)) +
61 | tm_borders(col = 'black')
62 |
63 |
64 | gran_santiago_plot
65 |
66 | ```
67 |
68 | ### Support
69 |
70 | FONDECYT Regular 2016 Nº 1161417, ¿Quién es responsable del desarrollo local? Una geografía política del neoestructuralismo en "comunas de exportación" (Comisión Nacional de Investigación Científica y Tecnológica).
71 |
72 | ### A note on usage
73 |
74 | When querying the API, please be respectful of the resources required to provide this data. Please retain the results for each request to avoid repeated requests for duplicate information.
75 |
76 | ### Installation
77 |
78 | ```R
79 | install.packages("devtools")
80 | devtools::install_github("robsalasco/sinimr")
81 | ```
82 |
83 | ### How do I use it?
84 |
85 | sinimR comes with a small set of functions to deliver the content of SINIM's webpage. To get a first glance of the categories of information what are available please use the ```get_sinim_cats()``` command.
86 |
87 | ```{r}
88 | library(sinimr)
89 | get_sinim_cats()
90 | ```
91 |
92 | Every category have a bunch of variables associated. Use the CODE number and the ```get_sinim_vars()``` function to get them.
93 |
94 | ```{r}
95 | get_sinim_vars(517)
96 | ```
97 |
98 | Finally, to obtain the data across municipalities use the code column and specify a year.
99 |
100 | ```{r}
101 | head(get_sinim(c(4210, 4211), 2015))
102 | ```
103 |
104 | By default the values are in **miles de millones** but it can be disabled using the ```truevalue = T``` switch.
105 |
106 | ```{r}
107 | head(get_sinim(c(4210, 4211), 2015, truevalue = T))
108 | ```
109 |
110 | You can get multiple years too! use the command ```get_sinim()``` and add more years as in the example.
111 |
112 | ```{r}
113 | head(get_sinim(880, 2015:2017))
114 | ```
115 |
116 | The geometries are available in long format using the ```geometry=T``` argument. By default it uses the **comunal** geographies but the **limite urbano censal** is also available. The switches are ```unit="comunas"``` and ```unit="limites"```. Note: Using **limites** not all features are available because some comunas are not related to urban zones. As shown in the example below you can obtain multiple years and variables in long format.
117 |
118 |
119 | ```{r}
120 | head(get_sinim(882, 2015:2017, geometry=T))
121 | ```
122 |
123 |
124 | Another interesting feature is the possibility to subset by different contexts. e.g if you want the comunas of Antofagasta region this command is available. The command works with or without the presence of the geometry switch and other switches are avaiblable too ```region```, ```provincia``` and ```comuna``` all working with codes.
125 |
126 | ```{r}
127 | head(get_sinim(882, 2015:2017, geometry=T, region=2))
128 | ```
129 |
130 | You can get a subset too
131 |
132 | ```{r}
133 | head(get_sinim(882, 2015:2017, geometry=T, region=c(2,3)))
134 | ```
135 |
136 | But where obtain the codes? a database is provided and you can filter it using the standard R functions.
137 |
138 | ```{r}
139 | head(id_geo_census)
140 | ```
141 |
142 | Related to variables if you don't know what are you looking for use ```search_sinim_vars()```to get search results based on variable descriptions, names and groups.
143 |
144 | ```{r}
145 | search_sinim_vars("cementerio")
146 | ```
147 |
148 | ## Advanced usage
149 |
150 | SINIM (Sistema Nacional de Información Municipal) by default applies a monetary correction to show current values of variables. The original values provided by municipalities are available using the ```moncorr = F``` switch. And if you want geographical identifiers like region or provincia you can apply them using ```idgeo = T``` switch.
151 |
152 | ### Other example plots
153 |
154 | #### Multiple variable faceted plot
155 |
156 | ```{r, message=F, fig.height=8, fig.width=15, fig.retina=2}
157 | library(tmap)
158 | library(dplyr)
159 | library(stringr)
160 | library(sinimr)
161 | library(sf)
162 |
163 | data_sinim <- get_sinim(var = c(3954,4174,880,1226,4251,4173),
164 | year = 2018,
165 | region = 13,
166 | geometry = T,
167 | truevalue = T,
168 | auc = T,
169 | unit = "limites")
170 |
171 | gran_santiago_plot <- tm_shape(data_sinim) +
172 | tm_fill(col = "value",
173 | palette = "BuPu",
174 | border.col = "white",
175 | border.alpha = 0.5,
176 | lwd=1,
177 | style = "jenks",
178 | title = "variable")+
179 | tm_text("municipality", size = 0.4) +
180 | tm_style("white", frame = T, legend.title.size = 1, legend.width=1) +
181 | tm_layout(inner.margins = c(0.01, 0.1, 0.1, 0.01),
182 | outer.margins = c(0.01, 0.01, 0.01, 0.01),
183 | design.mode=F,
184 | legend.format = list(text.separator = "a",
185 | fun = mm))+
186 | tm_borders(col = 'black') +
187 | tm_facets(by="variable", ncol = 2)
188 |
189 | gran_santiago_plot
190 |
191 | ```
192 |
193 | #### A variable in multiple years using facets
194 |
195 | ```{r, message=F, fig.height=10, fig.width=18, fig.retina=2}
196 | library(dplyr)
197 | library(sinimr)
198 | library(sf)
199 | library(tmap)
200 |
201 |
202 | var <- get_sinim(c(880, 882, 1226),
203 | 2016:2018,
204 | region = 13,
205 | truevalue = T,
206 | geometry = T,
207 | auc = T,
208 | unit = "limites")
209 |
210 | gran_santiago_plot <- tm_shape(var) +
211 | tm_fill("value",
212 | palette="BuPu",
213 | border.col = "white",
214 | style = "jenks",
215 | border.alpha = 0.5,
216 | lwd=1) +
217 | tm_text("municipality", size = 0.4) +
218 | tm_legend(legend.position = c("left", "top")) +
219 | tm_layout(legend.width=0.09,
220 | inner.margins = c(0.01, 0.1, 0.1, 0.01),
221 | outer.margins = c(0.01, 0.01, 0.01, 0.01),
222 | legend.format = list(text.separator = "a",
223 | fun = mm)) +
224 | tm_facets(by=c("year","variable"),) +
225 | tm_borders(col = 'black')
226 |
227 | gran_santiago_plot
228 |
229 | ```
230 |
231 | #### Multiple variables and years using geofacet
232 |
233 | ```{r, message=F, fig.height=12, fig.width=24, fig.retina=2}
234 | library(sf)
235 | library(dplyr)
236 | library(geofacet)
237 | library(sinimr)
238 | library(ggplot2)
239 | library(zoo)
240 | library(scales)
241 | library(ggpubr)
242 |
243 | data <- get_sinim(882, 2002:2018,
244 | region = 13,
245 | moncorr = F,
246 | truevalue = T,
247 | auc = T)
248 |
249 | data$year <- as.numeric(as.character(data$year))
250 | data$year <- as.Date(as.yearmon(data$year, "1-%y"))
251 |
252 | reg13 <- geogrid::read_polygons("https://raw.githubusercontent.com/robsalasco/precenso_2016_geojson_chile/master/Extras/GRAN_SANTIAGO.geojson")
253 | grd <- grid_auto(reg13, seed = 1, names = "NOM_COMUNA", codes = "COMUNA")
254 |
255 | #grid_preview(grd, label = "name_NOM_COMUNA")
256 | #grid_design(grd, label = "name_NOM_COMUNA")
257 |
258 | ggplot(data, aes(year, value, group=1)) +
259 | geom_line(color = "steelblue") +
260 | facet_geo(~ municipality, grid = grd, scales = "free_y")+
261 | scale_x_date() +
262 | scale_y_continuous(labels = dollar_format(suffix = "", prefix = "$", big.mark = ".", decimal.mark=","))+
263 | theme_bw()
264 | ```
265 |
266 |
267 | ### Citation
268 |
269 | ```{r}
270 | citation("sinimr")
271 | ```
272 |
273 | ### References
274 |
275 | - Sistema Nacional de Información Municipal (SINIM), SUBDERE, Ministerio del Interior.
276 |
277 |
--------------------------------------------------------------------------------
/docs/articles/creating-geofacets.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Creating geofacets with sinimR • sinimR
9 |
10 |
11 |
12 |
13 |
14 |
15 |
19 |
20 |
21 |
22 |
78 |
79 |
89 |
90 |
91 |
92 |
93 |
94 | Description
95 |
When you need to get a global overview of a phenomenom it’s difficult to have a plot with all the data. One option to achieve the goal are the use of facets but what if you want an spatial view? geofacets are the answer.
96 |
library (sf)
97 | library (dplyr)
98 | library (geofacet)
99 | library (sinimr)
100 | library (ggplot2)
101 | library (zoo)
102 | library (scales)
103 | library (ggpubr)
104 |
105 | data <- get_sinim (882 , 2002 : 2018 ,
106 | region = 13 ,
107 | moncorr = F,
108 | truevalue = T,
109 | auc = T)
110 |
111 | data$ year <- as.numeric (as.character (data$ year))
112 | data$ year <- as.Date (as.yearmon (data$ year, "1-%y" ))
113 |
114 | reg13 <- geogrid:: read_polygons ("https://raw.githubusercontent.com/robsalasco/precenso_2016_geojson_chile/master/Extras/GRAN_SANTIAGO.geojson" )
115 | grd <- grid_auto (reg13, seed = 1 , names = "NOM_COMUNA" , codes = "COMUNA" )
116 |
117 | #grid_preview(grd, label = "name_NOM_COMUNA")
118 | #grid_design(grd, label = "name_NOM_COMUNA")
119 |
120 | ggplot (data, aes (year, value, group= 1 )) +
121 | geom_line (color = "steelblue" ) +
122 | facet_geo (~ municipality, grid = grd, scales = "free_y" )+
123 | scale_x_date () +
124 | scale_y_continuous (labels = dollar_format (suffix = "" , prefix = "$" , big.mark = "." , decimal.mark= "," ))+
125 | theme_bw ()
126 |
127 |
128 |
129 |
138 |
139 |
140 |
141 |
142 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/docs/docsearch.css:
--------------------------------------------------------------------------------
1 | /* Docsearch -------------------------------------------------------------- */
2 | /*
3 | Source: https://github.com/algolia/docsearch/
4 | License: MIT
5 | */
6 |
7 | .algolia-autocomplete {
8 | display: block;
9 | -webkit-box-flex: 1;
10 | -ms-flex: 1;
11 | flex: 1
12 | }
13 |
14 | .algolia-autocomplete .ds-dropdown-menu {
15 | width: 100%;
16 | min-width: none;
17 | max-width: none;
18 | padding: .75rem 0;
19 | background-color: #fff;
20 | background-clip: padding-box;
21 | border: 1px solid rgba(0, 0, 0, .1);
22 | box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175);
23 | }
24 |
25 | @media (min-width:768px) {
26 | .algolia-autocomplete .ds-dropdown-menu {
27 | width: 175%
28 | }
29 | }
30 |
31 | .algolia-autocomplete .ds-dropdown-menu::before {
32 | display: none
33 | }
34 |
35 | .algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] {
36 | padding: 0;
37 | background-color: rgb(255,255,255);
38 | border: 0;
39 | max-height: 80vh;
40 | }
41 |
42 | .algolia-autocomplete .ds-dropdown-menu .ds-suggestions {
43 | margin-top: 0
44 | }
45 |
46 | .algolia-autocomplete .algolia-docsearch-suggestion {
47 | padding: 0;
48 | overflow: visible
49 | }
50 |
51 | .algolia-autocomplete .algolia-docsearch-suggestion--category-header {
52 | padding: .125rem 1rem;
53 | margin-top: 0;
54 | font-size: 1.3em;
55 | font-weight: 500;
56 | color: #00008B;
57 | border-bottom: 0
58 | }
59 |
60 | .algolia-autocomplete .algolia-docsearch-suggestion--wrapper {
61 | float: none;
62 | padding-top: 0
63 | }
64 |
65 | .algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column {
66 | float: none;
67 | width: auto;
68 | padding: 0;
69 | text-align: left
70 | }
71 |
72 | .algolia-autocomplete .algolia-docsearch-suggestion--content {
73 | float: none;
74 | width: auto;
75 | padding: 0
76 | }
77 |
78 | .algolia-autocomplete .algolia-docsearch-suggestion--content::before {
79 | display: none
80 | }
81 |
82 | .algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header {
83 | padding-top: .75rem;
84 | margin-top: .75rem;
85 | border-top: 1px solid rgba(0, 0, 0, .1)
86 | }
87 |
88 | .algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column {
89 | display: block;
90 | padding: .1rem 1rem;
91 | margin-bottom: 0.1;
92 | font-size: 1.0em;
93 | font-weight: 400
94 | /* display: none */
95 | }
96 |
97 | .algolia-autocomplete .algolia-docsearch-suggestion--title {
98 | display: block;
99 | padding: .25rem 1rem;
100 | margin-bottom: 0;
101 | font-size: 0.9em;
102 | font-weight: 400
103 | }
104 |
105 | .algolia-autocomplete .algolia-docsearch-suggestion--text {
106 | padding: 0 1rem .5rem;
107 | margin-top: -.25rem;
108 | font-size: 0.8em;
109 | font-weight: 400;
110 | line-height: 1.25
111 | }
112 |
113 | .algolia-autocomplete .algolia-docsearch-footer {
114 | width: 110px;
115 | height: 20px;
116 | z-index: 3;
117 | margin-top: 10.66667px;
118 | float: right;
119 | font-size: 0;
120 | line-height: 0;
121 | }
122 |
123 | .algolia-autocomplete .algolia-docsearch-footer--logo {
124 | background-image: url("data:image/svg+xml;utf8, ");
125 | background-repeat: no-repeat;
126 | background-position: 50%;
127 | background-size: 100%;
128 | overflow: hidden;
129 | text-indent: -9000px;
130 | width: 100%;
131 | height: 100%;
132 | display: block;
133 | transform: translate(-8px);
134 | }
135 |
136 | .algolia-autocomplete .algolia-docsearch-suggestion--highlight {
137 | color: #FF8C00;
138 | background: rgba(232, 189, 54, 0.1)
139 | }
140 |
141 |
142 | .algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight {
143 | box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5)
144 | }
145 |
146 | .algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content {
147 | background-color: rgba(192, 192, 192, .15)
148 | }
149 |
--------------------------------------------------------------------------------
/docs/reference/get_sinim_cats.html:
--------------------------------------------------------------------------------
1 |
2 | Get SINIM data categories — get_sinim_cats • sinimR
6 |
7 |
8 |
9 |
44 |
45 |
50 |
51 |
52 |
Get SINIM data categories
53 |
54 |
55 |
58 |
59 |
60 |
Value
61 |
Returns a data frame with available data in SINIM's webpage
62 |
63 |
64 |
65 |
Examples
66 |
get_sinim_cats ( )
67 | #> $`-`
68 | #> variable code
69 | #> 1 * SIM FIMU 539
70 | #>
71 | #> $`01. ADMINISTRACION Y FINANZAS MUNICIPALES`
72 | #> variable code
73 | #> 1 A.1. PRESUPUESTO INICIAL Y VIGENTE MUNICIPAL (M$) 517
74 | #> 2 A. INGRESOS MUNICIPALES (M$) 21
75 | #> 3 B. INGRESOS MUNICIPALES (%) 191
76 | #> 4 C. GASTOS MUNICIPALES (M$) 22
77 | #> 5 D. GASTOS MUNICIPALES (%) 172
78 | #> 6 E. GASTOS EN PERSONAL 169
79 | #> 7 F. TRANSFERENCIAS E INVERSION 170
80 | #> 8 G. SERVICIOS BASICOS Y GENERALES 370
81 | #> 9 I. TRANSFERENCIAS Y COMPENSACIONES SUBDERE 485
82 | #> 10 J. FONDO COMÚN MUNICIPAL (FCM) 508
83 | #> 11 K. GESTION MUNICIPAL 486
84 | #> 12 L. 24
85 | #> 13 M. 506
86 | #>
87 | #> $`02. RECURSOS HUMANOS MUNICIPAL`
88 | #> variable code
89 | #> 1 A. PERSONAL DE PLANTA 381
90 | #> 2 B. PERSONAL A CONTRATA 382
91 | #> 3 C. HONORARIOS 383
92 | #> 4 D. OTROS INDICADORES 384
93 | #>
94 | #> $`03. EDUCACION MUNICIPAL`
95 | #> variable code
96 | #> 1 A. ANTECEDENTES GENERALES DE EDUCACION 38
97 | #> 2 B. ASISTENCIA Y MATRÍCULAS EN EDUCACION 32
98 | #> 3 C. RESULTADOS PAES 33
99 | #> 4 D. INGRESOS EN EDUCACION MUNICIPAL 35
100 | #> 5 E. GASTOS EN EDUCACION MUNICIPAL 36
101 | #> 6 F. RECURSOS HUMANOS EN SECTOR EDUCACION 34
102 | #> 7 G. ESTABLECIMIENTOS DE EDUCACION MUNICIPAL 379
103 | #>
104 | #> $`04. SALUD MUNICIPAL`
105 | #> variable code
106 | #> 1 A. ANTECEDENTES GENERALES DE SALUD 30
107 | #> 2 B. COBERTURA EN SALUD MUNICIPAL 25
108 | #> 3 C. INGRESOS EN SALUD MUNICIPAL 26
109 | #> 4 D. GASTOS EN SALUD MUNICIPAL 28
110 | #> 5 E. RED ASISTENCIAL SALUD 31
111 | #> 6 F. RECURSOS HUMANOS EN SALUD 362
112 | #>
113 | #> $`05. SOCIAL Y COMUNITARIA`
114 | #> variable code
115 | #> 1 A. INFORMACION ENCUESTA CASEN 47
116 | #> 2 B. RED SOCIAL (SUBSIDIOS Y PENSIONES) 44
117 | #> 3 C. INTERMEDIACION LABORAL 43
118 | #> 4 D. ORGANIZACIONES COMUNITARIAS 46
119 | #> 5 E. BECAS 377
120 | #> 6 F. PARTICIPACIÓN CIUDADANA 510
121 | #> 7 G. DISCAPACIDAD 512
122 | #> 8 H. PREVENCIÓN DEL DELITO Y SEGURIDAD 511
123 | #> 9 L. RSH - ANTECEDENTES GENERALES 560
124 | #> 10 N.RSH - NIVEL INGRESOS - VULNERABILIDAD 561
125 | #> 11 O.RSH - CARACTERISTICAS ENCUESTADOS 562
126 | #> 12 P. INE - TIPO DE HOGARES 563
127 | #> 13 RETIROS 10% 565
128 | #>
129 | #> $`06. DESARROLLO Y GESTION TERRITORIAL`
130 | #> variable code
131 | #> 1 A. CARACTERISTICAS TERRITORIALES 39
132 | #> 2 B. SERVICIOS BASICOS A LA COMUNIDAD 41
133 | #> 3 C. INFRAESTRUCTURA 40
134 | #> 4 D. CATASTRO PREDIOS Y VALORACION CATASTRAL 300
135 | #> 5 E. AREAS VERDES 376
136 | #> 6 F. PLAN DE DESARROLLO COMUNAL (PLADECO) 304
137 | #> 7 G. PLAN REGULADOR COMUNAL 42
138 | #> 8 H. CULTURA 587
139 | #>
140 | #> $`07. CARACTERIZACION COMUNAL`
141 | #> variable code
142 | #> 1 A. GEOGRAFICO ADMINISTRATIVA 49
143 | #> 2 B. POBLACION 50
144 | #>
145 | #> $`08. GENERO`
146 | #> variable code
147 | #> 1 DOTACION MUNICIPAL HOMBRES Y MUJERES 262
148 | #>
149 | #> $`09. CEMENTERIO`
150 | #> variable code
151 | #> 1 1. INFORMACION GENERAL 516
152 | #> 2 A. INGRESOS CEMENTERIO (M$) 456
153 | #> 3 B. GASTOS CEMENTERIO (M$) 457
154 | #>
155 |
156 |
157 |
158 |
161 |
162 |
163 |
164 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
--------------------------------------------------------------------------------