├── .Rbuildignore
├── .Rhistory
├── .github
├── .gitignore
└── workflows
│ ├── R-CMD-check.yaml
│ ├── pkgcheck.yaml
│ └── rhub.yaml
├── .gitignore
├── CRAN-SUBMISSION
├── DESCRIPTION
├── LICENSE
├── LICENSE.md
├── Meta
└── vignette.rds
├── NAMESPACE
├── NEWS.md
├── R
├── .Rhistory
├── .gitignore
├── CNO.R
├── adulto_equivalente.R
├── caes.R
├── calculate_errors.R
├── calculate_poverty.R
├── calculate_tabulates.R
├── canastas_reg_example.R
├── centroides_aglomerados.R
├── diccionario_aglomerados.R
├── diccionario_regiones.R
├── eph.R
├── errores_muestrales.R
├── get_eahu.R
├── get_eahu_internal.R
├── get_microdata.R
├── get_microdata_internal.R
├── get_poverty_lines.R
├── get_total_urbano.R
├── get_total_urbano_internal.R
├── is_in_github.R
├── map_agglomerates.R
├── organize_caes.R
├── organize_cno.R
├── organize_labels.R
├── organize_panels.R
├── python
│ └── epyh.py
├── toybase_hogar_2016_04.R
├── toybase_individual_2016_03.R
├── toybase_individual_2016_04.R
└── utils-pipe.R
├── README.Rmd
├── README.md
├── codecov.yml
├── codemeta.json
├── data-raw
├── .Rhistory
├── aglomerados_geo.R
├── caes.R
└── errores_muestrales.R
├── data
├── CNO.rda
├── adulto_equivalente.rda
├── caes.rda
├── canastas_reg_example.rda
├── centroides_aglomerados.rda
├── diccionario_aglomerados.rda
├── diccionario_regiones.rda
├── errores_muestrales.rda
├── toybase_hogar_2016_04.rda
├── toybase_individual_2016_03.rda
└── toybase_individual_2016_04.rda
├── doc
├── eph.R
├── eph.Rmd
└── eph.html
├── docs
├── 404.html
├── CONTRIBUTING.md
├── LICENSE-text.html
├── LICENSE.html
├── apple-touch-icon-120x120.png
├── apple-touch-icon-152x152.png
├── apple-touch-icon-180x180.png
├── apple-touch-icon-60x60.png
├── apple-touch-icon-76x76.png
├── apple-touch-icon.png
├── articles
│ ├── eph.html
│ ├── eph_files
│ │ ├── figure-html
│ │ │ ├── unnamed-chunk-13-1.png
│ │ │ ├── unnamed-chunk-14-1.png
│ │ │ ├── unnamed-chunk-15-1.png
│ │ │ ├── unnamed-chunk-17-1.png
│ │ │ ├── unnamed-chunk-18-1.png
│ │ │ └── unnamed-chunk-19-1.png
│ │ └── header-attrs-2.9
│ │ │ └── header-attrs.js
│ ├── estimacion_pobreza.html
│ ├── estimacion_pobreza_files
│ │ ├── figure-html
│ │ │ ├── unnamed-chunk-10-1.png
│ │ │ ├── unnamed-chunk-11-1.png
│ │ │ ├── unnamed-chunk-12-1.png
│ │ │ ├── unnamed-chunk-13-1.png
│ │ │ ├── unnamed-chunk-14-1.png
│ │ │ ├── unnamed-chunk-15-1.png
│ │ │ ├── unnamed-chunk-6-1.png
│ │ │ ├── unnamed-chunk-7-1.png
│ │ │ ├── unnamed-chunk-8-1.png
│ │ │ └── unnamed-chunk-9-1.png
│ │ └── header-attrs-2.9
│ │ │ └── header-attrs.js
│ └── index.html
├── authors.html
├── bootstrap-toc.css
├── bootstrap-toc.js
├── docsearch.css
├── docsearch.js
├── favicon-16x16.png
├── favicon-32x32.png
├── favicon.ico
├── index.html
├── link.svg
├── logo.png
├── news
│ └── index.html
├── pkgdown.css
├── pkgdown.js
├── pkgdown.yml
├── reference
│ ├── CNO.html
│ ├── Rplot001.png
│ ├── adulto_equivalente.html
│ ├── caes.html
│ ├── calculate_errors.html
│ ├── calculate_poverty.html
│ ├── calculate_tabulates.html
│ ├── canastas_reg_example.html
│ ├── centroides_aglomerados.html
│ ├── diccionario_aglomerados.html
│ ├── diccionario_regiones.html
│ ├── eph.html
│ ├── errores_muestrales.html
│ ├── figures
│ │ └── logo.png
│ ├── get_eahu.html
│ ├── get_microdata.html
│ ├── get_microdata_internal.html
│ ├── get_poverty_lines.html
│ ├── get_total_urbano.html
│ ├── index.html
│ ├── is_in_github.html
│ ├── libs
│ │ ├── Proj4Leaflet-1.0.1
│ │ │ └── proj4leaflet.js
│ │ ├── htmlwidgets-1.5.1
│ │ │ └── htmlwidgets.js
│ │ ├── htmlwidgets-1.5.4
│ │ │ └── htmlwidgets.js
│ │ ├── htmlwidgets-1.6.1
│ │ │ └── htmlwidgets.js
│ │ ├── htmlwidgets-1.6.2
│ │ │ └── htmlwidgets.js
│ │ ├── leaflet-1.3.1
│ │ │ ├── images
│ │ │ │ ├── layers-2x.png
│ │ │ │ ├── layers.png
│ │ │ │ ├── marker-icon-2x.png
│ │ │ │ ├── marker-icon.png
│ │ │ │ └── marker-shadow.png
│ │ │ ├── leaflet.css
│ │ │ └── leaflet.js
│ │ ├── leaflet-binding-2.0.3
│ │ │ └── leaflet.js
│ │ ├── leaflet-binding-2.1.1
│ │ │ └── leaflet.js
│ │ ├── leaflet-binding-2.2.0
│ │ │ └── leaflet.js
│ │ ├── leaflet-providers-1.13.0
│ │ │ └── leaflet-providers_1.13.0.js
│ │ ├── leaflet-providers-1.9.0
│ │ │ └── leaflet-providers_1.9.0.js
│ │ ├── leaflet-providers-plugin-2.0.3
│ │ │ └── leaflet-providers-plugin.js
│ │ ├── leaflet-providers-plugin-2.1.1
│ │ │ └── leaflet-providers-plugin.js
│ │ ├── leaflet-providers-plugin-2.2.0
│ │ │ └── leaflet-providers-plugin.js
│ │ ├── leafletfix-1.0.0
│ │ │ └── leafletfix.css
│ │ ├── proj4-2.6.2
│ │ │ └── proj4.min.js
│ │ └── rstudio_leaflet-1.3.1
│ │ │ ├── images
│ │ │ └── 1px.png
│ │ │ └── rstudio_leaflet.css
│ ├── map_agglomerates.html
│ ├── map_aglomerados.html
│ ├── organize_caes.html
│ ├── organize_cno.html
│ ├── organize_labels.html
│ ├── organize_ocupations.html
│ ├── organize_panels.html
│ ├── pipe.html
│ ├── toybase_hogar_2016_04.html
│ ├── toybase_individual_2016_03.html
│ └── toybase_individual_2016_04.html
└── sitemap.xml
├── eph.Rproj
├── inst
└── CITATION
├── man
├── CNO.Rd
├── adulto_equivalente.Rd
├── caes.Rd
├── calculate_errors.Rd
├── calculate_poverty.Rd
├── calculate_tabulates.Rd
├── canastas_reg_example.Rd
├── centroides_aglomerados.Rd
├── diccionario_aglomerados.Rd
├── diccionario_regiones.Rd
├── errores_muestrales.Rd
├── figures
│ └── logo.png
├── get_eahu.Rd
├── get_microdata.Rd
├── get_poverty_lines.Rd
├── get_total_urbano.Rd
├── map_agglomerates.Rd
├── organize_caes.Rd
├── organize_cno.Rd
├── organize_labels.Rd
├── organize_panels.Rd
├── pipe.Rd
├── toybase_hogar_2016_04.Rd
├── toybase_individual_2016_03.Rd
└── toybase_individual_2016_04.Rd
├── pkgdown
├── _pkgdown.yml
└── favicon
│ ├── apple-touch-icon-120x120.png
│ ├── apple-touch-icon-152x152.png
│ ├── apple-touch-icon-180x180.png
│ ├── apple-touch-icon-60x60.png
│ ├── apple-touch-icon-76x76.png
│ ├── apple-touch-icon.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ └── favicon.ico
├── tests
├── testthat.R
└── testthat
│ ├── test-calculate_errors.R
│ ├── test-calculate_poverty.R
│ ├── test-calculate_tabulates.R
│ ├── test-get_eahu.R
│ ├── test-get_microdata.R
│ ├── test-get_poverty_lines.R
│ ├── test-get_total_urbano.R
│ ├── test-is_in_github.R
│ ├── test-map_agglomerates.R
│ ├── test-organize_caes.R
│ ├── test-organize_cno.R
│ ├── test-organize_labels.R
│ └── test-organize_panels.R
└── vignettes
├── .gitignore
├── eph.Rmd
└── estimacion_pobreza.Rmd
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | ^Meta$
2 | ^doc$
3 | ^LICENSE\.md$
4 | ^data-raw$
5 | ^eph\.Rproj$
6 | ^\.Rproj\.user$
7 | ^codecov\.yml$
8 | ^cran-comments\.md$
9 | ^CRAN-RELEASE$
10 | ^docs/
11 | ^_pkgdown\.yml$
12 | ^docs$
13 | ^pkgdown$
14 | ^\.github$
15 | ^CRAN-SUBMISSION$
16 | ^codemeta\.json
17 | ^\.DS_Store
18 | ^README\.Rmd$
19 | ^codemeta\.json$
20 |
--------------------------------------------------------------------------------
/.github/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 |
--------------------------------------------------------------------------------
/.github/workflows/R-CMD-check.yaml:
--------------------------------------------------------------------------------
1 | # For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
2 | # https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
3 | on:
4 | push:
5 | branches:
6 | - main
7 | - master
8 | pull_request:
9 | branches:
10 | - main
11 | - master
12 | schedule:
13 | # Agrego scheduler para que corra el check todos los sábados
14 | - cron: '* * * * 6'
15 |
16 | name: R-CMD-check
17 |
18 | jobs:
19 | R-CMD-check:
20 | runs-on: ${{ matrix.config.os }}
21 |
22 | name: ${{ matrix.config.os }} (${{ matrix.config.r }})
23 |
24 | strategy:
25 | fail-fast: false
26 | matrix:
27 | config:
28 | - {os: windows-latest, r: 'release'}
29 | - {os: macOS-latest, r: 'release'}
30 | - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
31 | - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
32 |
33 | env:
34 | R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
35 | RSPM: ${{ matrix.config.rspm }}
36 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
37 |
38 | steps:
39 | - uses: actions/checkout@v2
40 |
41 | - uses: r-lib/actions/setup-r@v2
42 | with:
43 | r-version: ${{ matrix.config.r }}
44 |
45 | - uses: r-lib/actions/setup-pandoc@v2
46 |
47 | - name: Query dependencies
48 | run: |
49 | install.packages('remotes')
50 | saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
51 | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
52 | shell: Rscript {0}
53 |
54 | - name: Cache R packages
55 | if: runner.os != 'Windows'
56 | uses: actions/cache@v2
57 | with:
58 | path: ${{ env.R_LIBS_USER }}
59 | key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
60 | restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
61 |
62 | - name: Install system dependencies
63 | if: runner.os == 'Linux'
64 | run: |
65 | while read -r cmd
66 | do
67 | eval sudo $cmd
68 | done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
69 |
70 | - name: Install dependencies
71 | run: |
72 | remotes::install_deps(dependencies = TRUE)
73 | remotes::install_cran("rcmdcheck")
74 | shell: Rscript {0}
75 |
76 | - name: Check
77 | env:
78 | _R_CHECK_CRAN_INCOMING_REMOTE_: false
79 | run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
80 | shell: Rscript {0}
81 |
82 | - name: Upload check results
83 | if: failure()
84 | uses: actions/upload-artifact@main
85 | with:
86 | name: ${{ runner.os }}-r${{ matrix.config.r }}-results
87 | path: check
88 |
--------------------------------------------------------------------------------
/.github/workflows/pkgcheck.yaml:
--------------------------------------------------------------------------------
1 | name: pkgcheck
2 |
3 | # This will cancel running jobs once a new run is triggered
4 | concurrency:
5 | group: ${{ github.workflow }}-${{ github.head_ref }}
6 | cancel-in-progress: true
7 |
8 | on:
9 | # Manually trigger the Action under Actions/pkgcheck
10 | workflow_dispatch:
11 | # Run on every push to main
12 | push:
13 | branches:
14 | - main
15 | - master
16 |
17 | jobs:
18 | pkgcheck:
19 | runs-on: ubuntu-latest
20 | steps:
21 | - uses: ropensci-review-tools/pkgcheck-action@main
22 |
--------------------------------------------------------------------------------
/.github/workflows/rhub.yaml:
--------------------------------------------------------------------------------
1 | # R-hub's generic GitHub Actions workflow file. It's canonical location is at
2 | # https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
3 | # You can update this file to a newer version using the rhub2 package:
4 | #
5 | # rhub::rhub_setup()
6 | #
7 | # It is unlikely that you need to modify this file manually.
8 |
9 | name: R-hub
10 | run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"
11 |
12 | on:
13 | workflow_dispatch:
14 | inputs:
15 | config:
16 | description: 'A comma separated list of R-hub platforms to use.'
17 | type: string
18 | default: 'linux,windows,macos'
19 | name:
20 | description: 'Run name. You can leave this empty now.'
21 | type: string
22 | id:
23 | description: 'Unique ID. You can leave this empty now.'
24 | type: string
25 |
26 | jobs:
27 |
28 | setup:
29 | runs-on: ubuntu-latest
30 | outputs:
31 | containers: ${{ steps.rhub-setup.outputs.containers }}
32 | platforms: ${{ steps.rhub-setup.outputs.platforms }}
33 |
34 | steps:
35 | # NO NEED TO CHECKOUT HERE
36 | - uses: r-hub/actions/setup@v1
37 | with:
38 | config: ${{ github.event.inputs.config }}
39 | id: rhub-setup
40 |
41 | linux-containers:
42 | needs: setup
43 | if: ${{ needs.setup.outputs.containers != '[]' }}
44 | runs-on: ubuntu-latest
45 | name: ${{ matrix.config.label }}
46 | strategy:
47 | fail-fast: false
48 | matrix:
49 | config: ${{ fromJson(needs.setup.outputs.containers) }}
50 | container:
51 | image: ${{ matrix.config.container }}
52 |
53 | steps:
54 | - uses: r-hub/actions/checkout@v1
55 | - uses: r-hub/actions/platform-info@v1
56 | with:
57 | token: ${{ secrets.RHUB_TOKEN }}
58 | job-config: ${{ matrix.config.job-config }}
59 | - uses: r-hub/actions/setup-deps@v1
60 | with:
61 | token: ${{ secrets.RHUB_TOKEN }}
62 | job-config: ${{ matrix.config.job-config }}
63 | - uses: r-hub/actions/run-check@v1
64 | with:
65 | token: ${{ secrets.RHUB_TOKEN }}
66 | job-config: ${{ matrix.config.job-config }}
67 |
68 | other-platforms:
69 | needs: setup
70 | if: ${{ needs.setup.outputs.platforms != '[]' }}
71 | runs-on: ${{ matrix.config.os }}
72 | name: ${{ matrix.config.label }}
73 | strategy:
74 | fail-fast: false
75 | matrix:
76 | config: ${{ fromJson(needs.setup.outputs.platforms) }}
77 |
78 | steps:
79 | - uses: r-hub/actions/checkout@v1
80 | - uses: r-hub/actions/setup-r@v1
81 | with:
82 | job-config: ${{ matrix.config.job-config }}
83 | token: ${{ secrets.RHUB_TOKEN }}
84 | - uses: r-hub/actions/platform-info@v1
85 | with:
86 | token: ${{ secrets.RHUB_TOKEN }}
87 | job-config: ${{ matrix.config.job-config }}
88 | - uses: r-hub/actions/setup-deps@v1
89 | with:
90 | job-config: ${{ matrix.config.job-config }}
91 | token: ${{ secrets.RHUB_TOKEN }}
92 | - uses: r-hub/actions/run-check@v1
93 | with:
94 | job-config: ${{ matrix.config.job-config }}
95 | token: ${{ secrets.RHUB_TOKEN }}
96 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Meta
2 | doc
3 | inst/doc
4 | .Rproj.user
5 | cran-comments.md
6 | .DS_Store
7 | .Rhistory
8 | .Rdata
9 | .httr-oauth
10 | /doc/
11 | /Meta/
12 |
--------------------------------------------------------------------------------
/CRAN-SUBMISSION:
--------------------------------------------------------------------------------
1 | Version: 1.0.2
2 | Date: 2024-06-23 14:59:15 UTC
3 | SHA: e1891166944515dc96bda0355e4c2b38f4b99a3e
4 |
--------------------------------------------------------------------------------
/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Package: eph
2 | Title: Argentina's Permanent Household Survey Data and Manipulation Utilities
3 | Version: 1.0.2
4 | Authors@R: c(
5 | person("Carolina", "Pradier", email = "carolinapradier@gmail.com", role = c("aut","cre"), comment = c(ORCID = "0009-0007-5058-6352")),
6 | person("Diego", "Kozlowski", email = "diegokoz92@gmail.com", role = c("aut"), comment = c(ORCID = "0000-0002-5396-3471")),
7 | person("Pablo", "Tiscornia", email = "pablotisco@gmail.com", role = "aut"),
8 | person("Guido", "Weksler", email = "guidowe45@gmail.com", role = c("aut")),
9 | person("Natsumi", "Shokida", email = "natsumi.shokida@gmail.com", role = "aut"),
10 | person("German", "Rosati", email = "german.rosati@gmail.com", role = "aut", comment = c(ORCID = "0000-0002-9775-0435")),
11 | person("Juan Gabriel", "Juara", email = "jg.juara@gmail.com", role = "ctb")
12 | )
13 | Description: Tools to download and manipulate the Permanent Household Survey from Argentina
14 | (EPH is the Spanish acronym for Permanent Household Survey).
15 | e.g: get_microdata() for downloading the datasets, get_poverty_lines() for downloading the official poverty baskets,
16 | calculate_poverty() for the calculation of stating if a household is in poverty or not, following the official methodology.
17 | organize_panels() is used to concatenate observations from different periods, and organize_labels()
18 | adds the official labels to the data. The implemented methods are based on INDEC (2016) .
19 | As this package works with the argentinian Permanent Household Survey and its main audience is from this country,
20 | the documentation was written in Spanish.
21 | BugReports: https://github.com/ropensci/eph/issues
22 | Imports:
23 | dplyr,
24 | expss,
25 | purrr,
26 | tibble,
27 | stringr,
28 | readxl,
29 | tidyr,
30 | utils,
31 | zoo,
32 | leaflet,
33 | htmltools,
34 | rlang,
35 | stats,
36 | cli,
37 | httr,
38 | curl,
39 | tidyselect
40 | Depends: R (>= 2.10)
41 | License: MIT + file LICENSE
42 | Encoding: UTF-8
43 | Language: es
44 | URL: https://github.com/ropensci/eph
45 | LazyData: true
46 | RoxygenNote: 7.2.3
47 | Suggests:
48 | testthat,
49 | lubridate,
50 | knitr,
51 | rmarkdown,
52 | ggplot2,
53 | readr,
54 | forcats,
55 | httptest
56 | VignetteBuilder: knitr
57 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | YEAR: 2019
2 | COPYRIGHT HOLDER: Diego Kozlowski
3 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | # MIT License
2 |
3 | Copyright (c) 2019 Diego Kozlowski
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Meta/vignette.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/Meta/vignette.rds
--------------------------------------------------------------------------------
/NAMESPACE:
--------------------------------------------------------------------------------
1 | # Generated by roxygen2: do not edit by hand
2 |
3 | export("%>%")
4 | export(calculate_errors)
5 | export(calculate_poverty)
6 | export(calculate_tabulates)
7 | export(get_eahu)
8 | export(get_microdata)
9 | export(get_poverty_lines)
10 | export(get_total_urbano)
11 | export(map_agglomerates)
12 | export(organize_caes)
13 | export(organize_cno)
14 | export(organize_labels)
15 | export(organize_panels)
16 | importFrom(dplyr,"%>%")
17 | importFrom(rlang,.data)
18 |
--------------------------------------------------------------------------------
/NEWS.md:
--------------------------------------------------------------------------------
1 | # eph 1.0.2
2 | * better adjusted to CRAN's policy 'Packages which use Internet resources should fail gracefully with an informative message if the resource is not available or has changed (and not give a check warning nor error).'
3 |
4 | # eph 1.0.1
5 | * fixed organize_labels bug
6 |
7 | # eph 1.0.0
8 | * added new functions: get_total_urbano() and get_eahu() (as well as their auxiliar internal functions)
9 | * improved documentation and site
10 | * added contributing and codemeta.json files
11 | * improved error messages using cli package
12 | * reduced dependencies relying on base r and improved deprecated code
13 | * re-structured functions using the early return philosophy
14 | * styled code according to the tidyverse style guide
15 | * modified get_microdata function to avoid parameter conflicts between trimester and wave
16 | * fixed map_agglomerates bug
17 | * added additional tests
18 |
19 |
20 | # eph 0.6.1
21 | * fixed bug in get_microdata() originated in a change in INDEC's URL (old datasets are now directly downloaded from a stable github repo)
22 |
23 | # eph 0.6.0
24 | * removed 'readr' and 'tidyverse' from Imports. readr was reclassified as a Suggest (because it was only used in a vignette) and tidyverse was replaced by the tidyverse packages actually required.
25 | * improved error messages in `calculate_tabulates()` function.
26 |
27 | # eph 0.5.1
28 | * fixed warnings when downloading poverty lines
29 |
30 | # eph 0.5.0
31 | * improve `get_microdata()` internals
32 | * remove `questionr` dependency
33 | * add group_vars and window argument to calculate_poverty
34 | * add function `calculate_errors()`
35 | * add affix_sign argument to `calculate_tabulates()`
36 |
37 | # eph 0.4.0
38 |
39 | * add option destfile to `get_microdata()`
40 | * add vignettes on poverty calculations
41 | * add option to `get_poverty_lines()` to download regional baskets
42 |
43 | # eph 0.3.1
44 |
45 | * rename organize_ocupations --> `organize_cno()` for consistency
46 | * add function `organize_caes()`
47 | * fixed compatibility with dplyr 1.0
48 |
49 | # eph 0.3.0
50 |
51 | * improve `get_microdata_internal()` internals
52 | * fixed compatibility with tibble 3.0.0
53 | * add dataset on centroids of aglomerates of the survey
54 | * add function `map_agglomerates()` for mapping indicators
55 |
56 | # eph 0.2.0
57 | * enhace `get_microdata()`. Now downloads multiple datasets and allows to pre-select variables
58 | * add skip_if_offline and some skip_on_cran for time-consuming tests
59 | * add stop if there is no internet connection for `get_microdata()`
60 | * add vignettes
61 | * simplify output in `organize_panels()`
62 | * add function organize_ocupations
63 |
64 |
65 | # eph 0.1.1
66 |
67 | * Added a `NEWS.md` file to track changes to the package.
68 | * Bug fix in `get_microdata()`
69 | * Added Authors@ information (orcid)
70 | * add bugreport to DESCRIPTION
71 |
72 |
73 |
--------------------------------------------------------------------------------
/R/.Rhistory:
--------------------------------------------------------------------------------
1 | load("C:/Users/usuario/Desktop/Guido/Trabajo/Repositorios de R/Repos Propios/holatam/eph/data/errores_muestrales.rda")
2 | View(errores_muestrales)
3 |
--------------------------------------------------------------------------------
/R/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
--------------------------------------------------------------------------------
/R/CNO.R:
--------------------------------------------------------------------------------
1 | #' Categorias de las 4 dimensiones del Clasificador Nacional de Ocupaciones 2001.
2 | #'
3 | #' @format Un data frame con 63 filas y 4 variables
4 | #'
5 | #' \describe{
6 | #' \item{digit}{digito para identificar la dimension del CNO}
7 | #' \item{value}{valor que toma cada categoria dentro de una dimension}
8 | #' \item{label}{nombre de la categoria propia a una dimension}
9 | #' \item{variable}{nombre de la dimension del CNO}
10 | #'
11 | #' }
12 | "CNO"
13 |
--------------------------------------------------------------------------------
/R/adulto_equivalente.R:
--------------------------------------------------------------------------------
1 | #' Tabla de valores de adulto equivalente segun sexo y edad
2 | #'
3 | #' @format Un data frame con 222 filas y 3 variables
4 | #'
5 | #' \describe{
6 | #' \item{CH04}{sexo}
7 | #' \item{CH06}{edad}
8 | #' \item{adequi}{unidades de adulto equivalente}
9 | #'
10 | #' }
11 | #'
12 | #' @details
13 | #' De acuerdo con la metodologia de [INDEC](https://www.indec.gob.ar/ftp/cuadros/sociedad/preguntas_frecuentes_cba_cbt.pdf):
14 | #'
15 | #' "Para identificar la unidad consumidora de referencia, o adulto equivalente, se analizo en que grupo de edad se ubicaba la mayor concentracion de poblacion activa, y fue la categoria de hombres de 30 a 60 anios de edad la que presentaba el mayor peso relativo dentro del conjunto total de la poblacion de referencia. Por este motivo se considero como adulto equivalente al hombre de 30 a 60 anios con un estilo de vida moderadamente activo y no otro grupo poblacional."
16 | #'
17 | "adulto_equivalente"
18 |
--------------------------------------------------------------------------------
/R/caes.R:
--------------------------------------------------------------------------------
1 | #' @title Categorias del Clasificador de Actividades Economicas para encuestas Sociodemograficas
2 | #' @description Base con codigos y etiquetas del Clasificador de actividades economicas para encuestas sociodemograficas.
3 | #' CAES Mercosur 1.0 - Actualizacion 2018.
4 | #' Basado en https://bit.ly/notas-explicativas-CAES-v2018 y
5 | #' https://www.indec.gob.ar/ftp/cuadros/menusuperior/clasificadores/caes_v2018.xls,
6 | #' obtenidos de
7 | #' https://www.indec.gob.ar/indec/web/Institucional-Indec-Clasificadores
8 | #' @format Un data frame con 140 filas y 8 variables:
9 | #' \describe{
10 | #' \item{caes_version}{(character) Version del CAES utilizada}
11 | #' \item{PP04B_COD}{(character) Codigo clase CAES. 4 digitos (nivel 3) Variable que aparece en microdatos EPH}
12 | #' \item{PP04B_label}{(character) Etiqueta clase CAES}
13 | #' \item{caes_seccion_cod}{(character) Codigo seccion CAES. 2 digitos (nivel 2)}
14 | #' \item{caes_seccion_label}{(character) Etiqueta seccion CAES}
15 | #' \item{caes_division_cod}{(character) Codigo division CAES. Letra (nivel 1)}
16 | #' \item{caes_division_label}{(character) Etiqueta division CAES}
17 | #' \item{caes_eph_cod}{(character) Codigo reagrupamiento de CAES utilizado por EPH (nivel 1)}
18 | #' \item{caes_eph_label}{(factor) Etiqueta reagrupamiento de CAES utilizado por EPH (nivel 1)}
19 | #' }
20 | "caes"
21 |
--------------------------------------------------------------------------------
/R/calculate_errors.R:
--------------------------------------------------------------------------------
1 | #' Calculo del desvio estandar y el coeficiente de variacion
2 | #' @description
3 | #' Asigna a una estimacion de un total poblacional el desvio estandar o el coeficiente de variacion
4 | #' correspondiente segun las tablas de error muestral de INDEC para EPH continua
5 | #' a partir del segundo trimestre 2003.
6 | #' (Ver `errores_muestrales`)
7 | #' @param value Vector numerico de las estimaciones de poblacion para las
8 | #' que se desea hallar el desvio estandar o el coeficiente de variacion.
9 | #' @param codigo_aglo default = "Total". String con el codigo numerico del aglomerado al que
10 | #' pertenecen las estimaciones. "Total" para trabajar estimaciones del conjunto de 31 aglomerados urbanos.
11 | #' @param periodo_eph default = "2014.03". String indicando el periodo al que corresponde la EPH. "2014.03" para
12 | #' obtener los errores muestrales correspondientes al tercer trimestre de 2014 en adelante. "2003.03_2014.02"
13 | #' para los errores muestrales del tercer trimestre del 2003 al segundo trimestre del 2014.
14 | #' @param measure default = "cv". String indicando la medida que se desea obtener. "cv" para obtener el coeficiente de variacion
15 | #' correspondiente a las estimaciones o "ds" para obtener el desvio estandar.
16 | #'
17 | #' @return Devuelve la estimacion de un total poblacional agregando el desvio estandar o el coeficiente de variacion correspondiente segun las tablas de error muestral de INDEC para EPH continua a partir del segundo trimestre 2003
18 | #'
19 | #' @details disclaimer: El script no es un producto oficial de INDEC.
20 | #'
21 | #' @examples
22 | #'
23 | #' tabla <- eph::toybase_individual_2016_03 %>%
24 | #' eph::organize_labels() %>%
25 | #' dplyr::filter(AGLOMERADO == 32) %>%
26 | #' eph::calculate_tabulates(
27 | #' x = "CH03",
28 | #' weights = "PONDERA",
29 | #' add.totals = "row"
30 | #' )
31 | #' tabla %>%
32 | #' dplyr::mutate(ds = calculate_errors(Freq,
33 | #' codigo_aglo = "32",
34 | #' periodo_eph = "2014.03", measure = "ds"
35 | #' ))
36 | #'
37 | #' @export
38 |
39 |
40 | calculate_errors <- function(value, codigo_aglo = "Total", periodo_eph = "2014.03", measure = "cv") {
41 |
42 | # Controles de los parametros
43 | if (!is.numeric(value)) {
44 | cli::cli_abort(c(
45 | "El argumento value debe ser numeric"
46 | ))
47 | }
48 | if (!codigo_aglo %in% c(
49 | "Total", "Gran Buenos Aires", "2", "3", "5", "4", "6", "7",
50 | "8", "9", "10", "12", "13", "14", "15", "17", "18", "19", "20",
51 | "22", "23", "25", "26", "27", "29", "30", "31", "32", "33", "34",
52 | "36", "38", "91", "93"
53 | )) {
54 | cli::cli_abort(c(
55 | "Elegir alguna de las opciones de codigo_aglo: el codigo numerico del aglomerado al que pertenecen las estimaciones o 'Total' para trabajar estimaciones del conjunto de 31 aglomerados urbanos."
56 | ))
57 | }
58 | if (!periodo_eph %in% c("2014.03", "2003.03_2014.02")) {
59 | cli::cli_abort(c(
60 | "Elegir alguna de las opciones de periodo_eph: '2014.03' o '2003.03_2014.02'."
61 | ))
62 | }
63 | if (!measure %in% c("cv", "ds")) {
64 | cli::cli_abort(c(
65 | "Elegir alguna de las opciones de measure: 'cv' o 'ds'."
66 | ))
67 | }
68 |
69 | # Operacion
70 | tabla_referencia <- eph::errores_muestrales %>%
71 | dplyr::filter(codigo == codigo_aglo & periodo == periodo_eph) %>%
72 | dplyr::select(tidyselect::all_of(c("x", measure)))
73 |
74 | find_closest <- function(y) {
75 | tabla_referencia[[measure]][which.min(abs(tabla_referencia[["x"]] - y))]
76 | }
77 |
78 | vapply(value, FUN = find_closest, FUN.VALUE = numeric(1))
79 | }
80 |
--------------------------------------------------------------------------------
/R/calculate_poverty.R:
--------------------------------------------------------------------------------
1 | #' Calculo de Pobreza e Indigencia
2 | #' @description
3 | #' Funcion para calcular la pobreza e indigencia siguiendo la metodologia de linea.
4 | #' @param base Base individual de uno o mas periodos
5 | #' @param basket canasta basica alimentaria y total, con la estructura de la canasta de ejemplo (ver `canastas_reg_example`)
6 | #' @param print_summary default = TRUE. Opcion para imprimir las tasas de pobreza e indigencia (proporcion de individuos)
7 | #' @param window default = "quarter". Opcion para cambiar el lapso del calculo que se imprime en consola.
8 | #' "quarter" (para estimacion trimestral) o "semester" (estimacion semestral)
9 | #' @param group_vars Opcion para agregar variables agrupadoras para el calculo que se imprime en consola.
10 | #'
11 | #' @return Devuelve la base agregando informacion respecto a la situacion de cada hogar en terminos de sus ingresos: indigente, pobre o no pobre (a estos fines, se agregan 5 columnas nuevas).
12 | #'
13 | #' @details disclaimer: El script no es un producto oficial de INDEC.
14 | #'
15 | #' @examples
16 | #'
17 | #' bases <- dplyr::bind_rows(
18 | #' toybase_individual_2016_03,
19 | #' toybase_individual_2016_04
20 | #' )
21 | #'
22 | #' base_pobreza <- calculate_poverty(
23 | #' base = bases,
24 | #' basket = canastas_reg_example,
25 | #' print_summary = TRUE,
26 | #' group_vars = c(CH04, NIVEL_ED),
27 | #' window = "semestral"
28 | #' )
29 | #'
30 | #' @export
31 |
32 | calculate_poverty <- function(base, basket, print_summary = TRUE, window = "quarter", group_vars = c()) {
33 | base <- base %>%
34 | dplyr::mutate(periodo = paste(ANO4, TRIMESTRE, sep = ".")) %>%
35 | dplyr::left_join(., adulto_equivalente, by = c("CH04", "CH06")) %>%
36 | dplyr::left_join(., basket, by = c("REGION" = "codigo", "periodo")) %>%
37 | dplyr::group_by(CODUSU, NRO_HOGAR, periodo) %>%
38 | dplyr::mutate(adequi_hogar = sum(adequi)) %>%
39 | dplyr::ungroup() %>%
40 | dplyr::mutate(
41 | CBA_hogar = CBA * adequi_hogar,
42 | CBT_hogar = CBT * adequi_hogar,
43 | situacion = dplyr::case_when(
44 | ITF < CBA_hogar ~ "indigente",
45 | ITF >= CBA_hogar & ITF < CBT_hogar ~ "pobre",
46 | ITF >= CBT_hogar ~ "no_pobre"
47 | ),
48 | # excluyo los casos que no tienen respuesta en ITF
49 | situacion = dplyr::case_when(
50 | PONDIH == 0 ~ NA_character_,
51 | TRUE ~ situacion
52 | )
53 | ) %>%
54 | dplyr::select(-tidyselect::any_of(c("adequi", "periodo", "CBA", "CBT")))
55 |
56 | if (print_summary) {
57 | if (window == "quarter") {
58 | Pobreza_resumen <- base %>%
59 | dplyr::group_by(ANO4, TRIMESTRE, dplyr::across(c({{ group_vars }}))) %>%
60 | dplyr::summarise(
61 | Tasa_pobreza = sum(PONDIH[situacion %in% c("pobre", "indigente")], na.rm = TRUE) /
62 | sum(PONDIH, na.rm = TRUE),
63 | Tasa_indigencia = sum(PONDIH[situacion == "indigente"], na.rm = TRUE) /
64 | sum(PONDIH, na.rm = TRUE)
65 | )
66 | } else {
67 | Pobreza_resumen <- base %>%
68 | dplyr::mutate(SEMESTRE = ifelse(TRIMESTRE %in% c(1, 2), yes = 1, no = 2)) %>%
69 | dplyr::group_by(ANO4, SEMESTRE, dplyr::across(c({{ group_vars }}))) %>%
70 | dplyr::summarise(
71 | Tasa_pobreza = sum(PONDIH[situacion %in% c("pobre", "indigente")], na.rm = TRUE) /
72 | sum(PONDIH, na.rm = TRUE),
73 | Tasa_indigencia = sum(PONDIH[situacion == "indigente"], na.rm = TRUE) /
74 | sum(PONDIH, na.rm = TRUE)
75 | )
76 | }
77 |
78 |
79 | print(Pobreza_resumen)
80 | }
81 | return(base)
82 | }
83 |
--------------------------------------------------------------------------------
/R/canastas_reg_example.R:
--------------------------------------------------------------------------------
1 | #' Canastas Basicas Alimentarias y Canastas Basicas Totales segun region y trimestre
2 | #'
3 | #' Esta base tiene el formato necesario para el calculo de pobreza
4 | #'
5 | #' @format Un data frame con 12 filas y 5 variables
6 | #'
7 | #' \describe{
8 | #' \item{region}{Nombre de region}
9 | #' \item{periodo}{Anio.trimestre}
10 | #' \item{CBA}{canasta basica alimentaria}
11 | #' \item{CBT}{inversa del coeficiente de engels}
12 | #' \item{codigo}{codigo de region}
13 | #' ...
14 | #' }
15 | "canastas_reg_example"
16 |
--------------------------------------------------------------------------------
/R/centroides_aglomerados.R:
--------------------------------------------------------------------------------
1 | #' @title Tabla de centroides de los aglomerados
2 | #' @description Base con centroides de los aglomerados de EPH.
3 | #' Basado en https://www.indec.gob.ar/indec/web/Nivel4-Tema-1-39-120
4 | #' @format Un data frame con 32 filas y 4 variables:
5 | #' \describe{
6 | #' \item{AGLOMERADO}{(Factor) Codigo de aglomerado EPH}
7 | #' \item{nombre_aglomerado}{(Factor) Nombre del aglomerado EPH}
8 | #' \item{lat}{Latitud del aglomerado EPH}
9 | #' \item{lon}{Longitud del aglomerado EPH}
10 | #' }
11 |
12 | "centroides_aglomerados"
13 |
--------------------------------------------------------------------------------
/R/diccionario_aglomerados.R:
--------------------------------------------------------------------------------
1 | #' Diccionario de aglomerados segun diseno de registro de la EPH
2 | #'
3 | #' @format Un data frame con 32 filas y 2 variables
4 | #'
5 | #' \describe{
6 | #' \item{codigo}{Codigo de aglomerado}
7 | #' \item{aglo}{Nombre del aglomerado}
8 | #'
9 | #' }
10 | "diccionario_aglomerados"
11 |
--------------------------------------------------------------------------------
/R/diccionario_regiones.R:
--------------------------------------------------------------------------------
1 | #' Diccionario de regiones segun diseno de registro de la EPH
2 | #'
3 | #' @format Un data frame con 6 filas y 2 variables
4 | #'
5 | #' \describe{
6 | #' \item{codigo}{Codigo de region}
7 | #' \item{region}{Nombre de region}
8 | #'
9 | #' }
10 | "diccionario_regiones"
11 |
--------------------------------------------------------------------------------
/R/eph.R:
--------------------------------------------------------------------------------
1 | #' `eph` package
2 | #'
3 | #' Caja de Herramientas para el procesamiento de la Encuesta Permanente de Hogares
4 | #'
5 | #' See the README on
6 | #' \href{https://github.com/holatam/eph/blob/master/README.md}{Github}
7 | #'
8 | #' @docType package
9 | #' @name eph
10 | #' @aliases eph-package
11 | #'
12 | #' @noRd
13 | NULL
14 |
15 | ## quiets concerns of R CMD check re: the .'s that appear in pipelines
16 | if (getRversion() >= "2.15.1") {
17 | utils::globalVariables(c(
18 | ".",
19 | "ANO4",
20 | "CBA",
21 | "CBT",
22 | "CH04",
23 | "CH06",
24 | "CODUSU",
25 | "COMPONENTE",
26 | "ESTADO",
27 | "Freq",
28 | "NRO_HOGAR",
29 | "PONDIH",
30 | "TRIMESTRE",
31 | "Trimestre",
32 | "Var2",
33 | "adequi",
34 | "adequi_hogar",
35 | "adulto_equivalente",
36 | "anio",
37 | "cba",
38 | "cbt",
39 | "con_controles",
40 | "consistencia",
41 | "ice",
42 | "link",
43 | "mes",
44 | "n",
45 | "periodo",
46 | "situacion",
47 | "put_labels_eph",
48 | "sin_controles",
49 | "microdata",
50 | "error",
51 | "filter_col",
52 | "error_message",
53 | ".data",
54 | "Periodo",
55 | "vars",
56 | "CNO",
57 | "digit",
58 | "value",
59 | "label",
60 | "PP04D_COD",
61 | "CLASIF_CNO",
62 | "DIGIT12",
63 | "DIGIT3",
64 | "DIGIT4",
65 | "DIGIT5",
66 | "centroides_aglomerados",
67 | "PP04B_CAES",
68 | "PP04B_COD",
69 | "caes",
70 | "SEMESTRE",
71 | "var",
72 | "valor",
73 | "aux",
74 | "prop",
75 | "codigo",
76 | "x"
77 | ))
78 | }
79 |
--------------------------------------------------------------------------------
/R/errores_muestrales.R:
--------------------------------------------------------------------------------
1 | #' @title Tabla con los errores muestrales para estimaciones de poblacion
2 | #' @description Base con los errores muestrales para estimaciones de poblacion en los aglomerados urbanos
3 | #' para la EPH continua desde 2003 segundo trimestre segun documentacion de INDEC:
4 | #' https://www.indec.gob.ar/ftp/cuadros/menusuperior/eph/EPH_errores_muestreo_3t2014.pdf
5 | #' https://www.indec.gob.ar/ftp/cuadros/menusuperior/eph/EPH_errores_muestreo.pdf
6 | #' @format Un data frame con 1687 filas y 5 variables:
7 | #' \describe{
8 | #' \item{\code{codigo}}{character ---String con codigo numerico de los 31 aglomerados, "Gran Buenos Aires"
9 | #' (solo para 2003.03 a 2014.02), o con "Total" para el conjunto de los 31 aglomerados---}
10 | #' \item{\code{aglomerado}}{character ---String con el nombre del aglomerado---}
11 | #' \item{\code{periodo}}{character ---String indicando el periodo de EPH que corresponde, "2014.03"
12 | #' para datos de EPH a partir del tercer trimestre 2014, o "2003.03_2014.02" para datos anteriores---}
13 | #' \item{\code{x}}{double ---Estimacion de poblacion para la cual se desea conocer el error muestral---}
14 | #' \item{\code{ds}}{double ---Desvio Estandar correspondiente a la estimacion de poblacion en el aglomerado---}
15 | #' \item{\code{cv}}{double ---Coeficiente de Variacion correspondiente a la estimacion de poblacion en el aglomerado---}
16 | #' }
17 |
18 | "errores_muestrales"
19 |
--------------------------------------------------------------------------------
/R/get_eahu.R:
--------------------------------------------------------------------------------
1 | #' Descarga de Bases de la Encuesta anual de hogares urbanos
2 | #' @description
3 | #' Funcion que descarga bases de la Encuesta anual de hogares urbanos del INDEC entre 2010 y 2014
4 | #' @param year un integer o vector de integers entre 2010 y 2014
5 | #' @param type tipo de base a descargar: 'individual' ; 'hogar'
6 | #' @param vars opcional: un vector de characters. variables a seleccionar. Default = 'all' trae todas las variables
7 | #' @param destfile opcional: un string con la direccion de un archivo .RDS. Si se ingresa un path a un archivo que no existe, se descarga
8 | #' el archivo y se graba en esa direccion. Si existe un archivo en ese path, se lee el archivo.
9 | #'
10 | #' @return Devuelve la o las bases de la EAHU solicitadas
11 | #'
12 | #' @details
13 | #' disclaimer: El script no es un producto oficial de INDEC.
14 | #'
15 | #' @examples
16 | #' \dontrun{
17 | #' base_individual <- get_eahu(
18 | #' year = 2010,
19 | #' type = "individual",
20 | #' vars = c("SUBDOMINIO", "PONDERA", "ESTADO", "CAT_OCUP")
21 | #' )
22 | #' }
23 | #'
24 | #' @export
25 |
26 | get_eahu <- function(year = 2010,
27 | type = "individual",
28 | vars = "all",
29 | destfile = NULL) {
30 |
31 | destfile_exists <- FALSE
32 | if (!is.null(destfile)) {
33 | destfile_exists <- file.exists(destfile)
34 | }
35 |
36 | if (destfile_exists) {
37 | df <- readRDS(destfile)
38 |
39 | return(df)
40 | }
41 |
42 |
43 | if (is.null(destfile) | !destfile_exists) {
44 | # attempt::stop_if_not(
45 | # .x = curl::has_internet(),
46 | # msg = "No se detecto acceso a internet. Por favor checkea tu conexion."
47 | # )
48 | if (!curl::has_internet()) { # network is down = message (not an error anymore)
49 | message("No se detecto acceso a internet. Por favor checkea tu conexion.")
50 | return(NULL)
51 | }
52 |
53 | df <- tibble::as_tibble(expand.grid(
54 | year = year,
55 | type = type
56 | ))
57 |
58 |
59 | df <- df %>%
60 | dplyr::mutate(
61 | microdata =
62 | purrr::pmap(
63 | list(
64 | "year" = year,
65 | "type" = type
66 | ),
67 | purrr::safely(
68 | .f = get_eahu_internal,
69 | otherwise = tibble::tibble(),
70 | quiet = TRUE
71 | ), vars
72 | )
73 | )
74 |
75 |
76 | df <- df %>%
77 | dplyr::mutate(
78 | error = purrr::map(microdata, ~ .x$error),
79 | microdata = purrr::map(microdata, ~ .x$result)
80 | )
81 |
82 | errors <- df %>%
83 | dplyr::mutate(filter_col = purrr::map_lgl(error, ~ !is.null(.x))) %>%
84 | dplyr::filter(filter_col) %>%
85 | dplyr::mutate(error_message = purrr::map(error, ~ purrr::pluck(.x, 1))) %>%
86 | dplyr::select(-tidyselect::any_of(c("microdata", "error"))) %>%
87 | tidyr::unnest(cols = c(error_message))
88 |
89 | if (nrow(errors) > 0) {
90 | warning(sprintf("No se pudo descargar la base de year %s, type %s.
91 | Mensaje: %s
92 |
93 | ", errors$year, errors$type, errors$error_message))
94 | }
95 |
96 | df <- df %>%
97 | dplyr::select(-tidyselect::any_of(c("error")))
98 |
99 | if (!is.null(destfile) & !destfile_exists) {
100 | saveRDS(df, file = destfile)
101 | }
102 | }
103 |
104 | if (nrow(df) == 1) {
105 | return(df$microdata[[1]])
106 | } else {
107 | df %>%
108 | tidyr::unnest(microdata) %>%
109 | dplyr::select(-tidyselect::any_of(c("year", "type")))
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/R/get_eahu_internal.R:
--------------------------------------------------------------------------------
1 | #' Descarga de Bases de la Encuesta anual de hogares urbanos
2 | #'
3 | #' @param year un integer entre 2010 y 2014
4 | #' @param type tipo de base a descargar: 'individual' ; 'hogar'
5 | #' @param vars variables a seleccionar. Default trae todas las variables
6 | #'
7 | #' @noRd
8 |
9 | get_eahu_internal <- function(year = 2010,
10 | type = "individual",
11 | vars = "all") {
12 | if (!is.numeric(year)) {
13 | cli::cli_abort(c(
14 | "El argumento year debe ser numeric"
15 | ))
16 | }
17 | if (year < 2010|year > 2014) {
18 | cli::cli_alert_warning(c(
19 | "La funcion puede descargar bases publicadas entre 2010 y 2014."
20 | ))
21 | }
22 | if (!type %in% c("individual", "hogar")) {
23 | cli::cli_abort(c(
24 | "Elegir alguna de las opciones de type: 'individual' u 'hogar'."
25 | ))
26 | }
27 |
28 | if (!year %in% 2010:2014) {
29 | cli::cli_abort(c(
30 | "El anio elegido no es valido",
31 | "i" = "Hay datos disponibles entre 2010 y 2014"
32 | ))
33 | }
34 |
35 |
36 | link <- sprintf("https://github.com/holatam/data/raw/master/eahu/%s/eahu_%s_%s.RDS", type, type, year)
37 |
38 | base <- emptyenv()
39 | try(base <- readRDS(gzcon(url(link))), silent = TRUE)
40 |
41 | if (rlang::is_empty(base)) {
42 | cli::cli_abort(c(
43 | "Problema con la descarga. Posiblemente un error de la conexion a internet"
44 | ))
45 | }
46 |
47 |
48 | if (all(vars == "all")) {
49 | base <- base %>%
50 | dplyr::rename_all(toupper)
51 |
52 | return(base)
53 | }
54 | if (nrow(base) > 0) {
55 | chequeo <- vars %in% toupper(colnames(base))
56 |
57 | if (!all(chequeo)) {
58 | cli::cli_abort(sprintf("Las variables: %s no se encuentran disponibles para esta base.
59 | Puede deberse a que son variables de la base individual (hogar) y se quiere descargar la base hogar (individual)", sub(",([^,]*)$", " y\\1", paste0(vars[!chequeo], collapse = ", "))))
60 | }
61 |
62 | base <- base %>%
63 | dplyr::rename_all(toupper) %>%
64 | dplyr::select(tidyselect::all_of(vars))
65 |
66 | return(base)
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/R/get_microdata.R:
--------------------------------------------------------------------------------
1 | #' Descarga de Bases de EPH
2 | #' @description
3 | #' Funcion que descarga bases de la Encuesta Permanente de Hogares del INDEC a partir de 1996
4 | #' @param year un integer o vector de integers a partir de 2003
5 | #' @param period un integer o vector de integers con el numero de trimestre u onda: 1,2,3,4, para la EPH continua, y 1 o 2, para la EPH puntual
6 | #' @param type un character o vector de characters con el tipo de base a descargar: 'individual'; 'hogar', default individual
7 | #' @param vars opcional: un vector de characters. variables a seleccionar. Default='all' trae todas las variables
8 | #' @param destfile opcional: un string con la direccion de un archivo .RDS. Si se ingresa un path a un archivo que no existe, se descarga
9 | #' el archivo y se graba en esa direccion. Si existe un archivo en ese path, se lee el archivo.
10 | #' @param ... asegura el funcionamiento de la funcion en su version anterior con los parametros wave o trimester
11 | #'
12 | #' @return Devuelve la o las bases de la EPH solicitadas
13 | #'
14 | #' @details
15 | #' Las bases de la EPH puntual utilizan el parametro period para referirse a las ondas.
16 | #' Su alcance es entre la onda 1 de 1996 y la onda 1 de 2003.
17 | #'
18 | #' Las bases de la EPH continua utilizan el parametro period para referirse a los trimestres.
19 | #' Su alcance es entre tercer trimestre de 2003 a la actualidad
20 | #' disclaimer: El script no es un producto oficial de INDEC.
21 | #'
22 | #' @examples
23 | #'
24 | #' base_individual <- get_microdata(
25 | #' year = 2018:2019,
26 | #' period = 1,
27 | #' type = "individual",
28 | #' vars = c("PONDERA", "ESTADO", "CAT_OCUP")
29 | #' )
30 | #'
31 | #' @export
32 |
33 | get_microdata <- function(year = 2018,
34 | period = 1,
35 | type = "individual",
36 | vars = "all",
37 | destfile = NULL, ...) {
38 |
39 | dots <- list(...)
40 |
41 | if ("trimester" %in% names(dots)) {
42 | period <- dots$trimester
43 | }
44 | if ("wave" %in% names(dots)) {
45 | period <- dots$wave
46 | }
47 |
48 | destfile_exists <- FALSE
49 | if (!is.null(destfile)) {
50 | destfile_exists <- file.exists(destfile)
51 | }
52 |
53 | if (destfile_exists) {
54 | df <- readRDS(destfile)
55 |
56 | return(df)
57 | }
58 |
59 |
60 | if (is.null(destfile) | !destfile_exists) {
61 | # attempt::stop_if_not(
62 | # .x = curl::has_internet(),
63 | # msg = "No se detecto acceso a internet. Por favor checkea tu conexion."
64 | # )
65 | if (!curl::has_internet()) { # network is down = message (not an error anymore)
66 | message("No se detecto acceso a internet. Por favor checkea tu conexion.")
67 | return(NULL)
68 | }
69 |
70 | df <- tibble::as_tibble(expand.grid(
71 | year = year,
72 | period = period,
73 | type = type
74 | ))
75 |
76 |
77 | df <- df %>%
78 | dplyr::mutate(
79 | microdata =
80 | purrr::pmap(
81 | list(
82 | "year" = year,
83 | "period" = period,
84 | "type" = type
85 | ),
86 | purrr::safely(
87 | .f = get_microdata_internal,
88 | otherwise = tibble::tibble(),
89 | quiet = TRUE
90 | ), vars
91 | )
92 | )
93 |
94 |
95 | df <- df %>%
96 | dplyr::mutate(
97 | error = purrr::map(microdata, ~ .x$error),
98 | microdata = purrr::map(microdata, ~ .x$result)
99 | )
100 |
101 | errors <- df %>%
102 | dplyr::mutate(filter_col = purrr::map_lgl(error, ~ !is.null(.x))) %>%
103 | dplyr::filter(filter_col) %>%
104 | dplyr::mutate(error_message = purrr::map(error, ~ purrr::pluck(.x, 1))) %>%
105 | dplyr::select(-tidyselect::any_of(c("microdata", "error"))) %>%
106 | tidyr::unnest(cols = c(error_message))
107 |
108 | if (nrow(errors) > 0) {
109 | warning(sprintf("No se pudo descargar la base de year %s, period %s, type %s.
110 | Mensaje: %s
111 |
112 | ", errors$year, errors$period, errors$type, errors$error_message))
113 | }
114 |
115 | df <- df %>%
116 | dplyr::select(-tidyselect::any_of(c("error")))
117 |
118 | if (!is.null(destfile) & !destfile_exists) {
119 | saveRDS(df, file = destfile)
120 | }
121 | }
122 |
123 | if (nrow(df) == 1) {
124 | return(df$microdata[[1]])
125 | } else {
126 | df %>%
127 | tidyr::unnest(microdata) %>%
128 | dplyr::select(-tidyselect::any_of(c("year", "period", "type")))
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/R/get_poverty_lines.R:
--------------------------------------------------------------------------------
1 | #' Descarga de canasta basica alimentaria y canasta basica total
2 | #' @description
3 | #' Funcion que descarga la CBA y CBT a partir de abril 2016
4 | #' @param regional booleano, default = FALSE. Si es TRUE, descarga los datos de canastas regionales
5 | #' que se utilizan para el calculo de pobreza. Si es FALSE, descarga la serie de GBA
6 | #' provista por indec en https://www.indec.gob.ar/indec/web/Nivel4-Tema-4-43-149
7 | #'
8 | #' @return Devuelve una tabla con la CBA y CBT a partir de abril 2016
9 | #'
10 | #' @details
11 | #' disclaimer: El script no es un producto oficial de INDEC.
12 | #'
13 | #' @examples
14 | #'
15 | #' canasta <- get_poverty_lines(regional = TRUE)
16 | #' canasta
17 | #'
18 | #' @export
19 |
20 | get_poverty_lines <- function(regional = FALSE) {
21 | # attempt::stop_if_not(
22 | # .x = curl::has_internet(),
23 | # msg = "No se detecto acceso a internet. Por favor checkea tu conexion."
24 | # )
25 | if (!curl::has_internet()) { # network is down = message (not an error anymore)
26 | message("No se detecto acceso a internet. Por favor checkea tu conexion.")
27 | return(NULL)
28 | }
29 |
30 | if (regional) {
31 | temp <- tempfile()
32 | link <- "https://github.com/holatam/data/raw/master/eph/canasta/canastas.rds"
33 |
34 | check <- NA
35 | try(check <- utils::download.file(link, destfile = temp, mode = "wb"), silent = TRUE)
36 | if (is.na(check)) {
37 | cli::cli_inform(c(
38 | "Problema con la descarga"
39 | ))
40 | return(NULL)
41 | }
42 |
43 | canasta <- readRDS(temp)
44 | unlink(temp)
45 | } else {
46 | temp <- tempfile(fileext = ".xls")
47 | dataURL <- "https://www.indec.gob.ar/ftp/cuadros/sociedad/serie_cba_cbt.xls"
48 |
49 | check <- NA
50 | try(check <- utils::download.file(dataURL, destfile = temp, mode = "wb"), silent = TRUE)
51 | if (is.na(check)) {
52 | cli::cli_inform(c(
53 | "Problema con la descarga"
54 | ))
55 | return(NULL)
56 | }
57 |
58 | suppressWarnings({
59 | canasta <- readxl::read_excel(temp,
60 | sheet = 1, skip = 6, col_names = c("periodo", "CBA", "ICE", "CBT"),
61 | col_types = c("date", "numeric", "numeric", "numeric")
62 | ) %>% stats::na.omit()
63 | })
64 | unlink(temp)
65 | }
66 |
67 | canasta
68 | }
69 |
--------------------------------------------------------------------------------
/R/get_total_urbano.R:
--------------------------------------------------------------------------------
1 | #' Descarga de Bases de EPH total urbano
2 | #' @description
3 | #' Funcion que descarga bases de la Encuesta Permanente de Hogares total urbano del INDEC a partir de 2016
4 | #' @param year un integer o vector de integers a partir de 2016
5 | #' @param type tipo de base a descargar: 'individual' ; 'hogar'
6 | #' @param vars opcional: un vector de characters. variables a seleccionar. Default = 'all' trae todas las variables
7 | #' @param destfile opcional: un string con la direccion de un archivo .RDS. Si se ingresa un path a un archivo que no existe, se descarga
8 | #' el archivo y se graba en esa direccion. Si existe un archivo en ese path, se lee el archivo.
9 | #'
10 | #' @return Devuelve la o las bases de la EPH total urbano solicitadas
11 | #'
12 | #' @details
13 | #' disclaimer: El script no es un producto oficial de INDEC.
14 | #'
15 | #' @examples
16 | #' \dontrun{
17 | #' base_individual <- get_total_urbano(
18 | #' year = 2016,
19 | #' type = "hogar",
20 | #' vars = c("PONDERA", "IV1", "IV2")
21 | #' )
22 | #' }
23 | #'
24 | #' @export
25 |
26 | get_total_urbano <- function(year = 2016,
27 | type = "individual",
28 | vars = "all",
29 | destfile = NULL) {
30 |
31 | destfile_exists <- FALSE
32 | if (!is.null(destfile)) {
33 | destfile_exists <- file.exists(destfile)
34 | }
35 |
36 | if (destfile_exists) {
37 | df <- readRDS(destfile)
38 |
39 | return(df)
40 | }
41 |
42 |
43 | if (is.null(destfile) | !destfile_exists) {
44 | # attempt::stop_if_not(
45 | # .x = curl::has_internet(),
46 | # msg = "No se detecto acceso a internet. Por favor checkea tu conexion."
47 | # )
48 | if (!curl::has_internet()) { # network is down = message (not an error anymore)
49 | message("No se detecto acceso a internet. Por favor checkea tu conexion.")
50 | return(NULL)
51 | }
52 |
53 | df <- tibble::as_tibble(expand.grid(
54 | year = year,
55 | type = type
56 | ))
57 |
58 |
59 | df <- df %>%
60 | dplyr::mutate(
61 | microdata =
62 | purrr::pmap(
63 | list(
64 | "year" = year,
65 | "type" = type
66 | ),
67 | purrr::safely(
68 | .f = get_total_urbano_internal,
69 | otherwise = tibble::tibble(),
70 | quiet = TRUE
71 | ), vars
72 | )
73 | )
74 |
75 |
76 | df <- df %>%
77 | dplyr::mutate(
78 | error = purrr::map(microdata, ~ .x$error),
79 | microdata = purrr::map(microdata, ~ .x$result)
80 | )
81 |
82 | errors <- df %>%
83 | dplyr::mutate(filter_col = purrr::map_lgl(error, ~ !is.null(.x))) %>%
84 | dplyr::filter(filter_col) %>%
85 | dplyr::mutate(error_message = purrr::map(error, ~ purrr::pluck(.x, 1))) %>%
86 | dplyr::select(-tidyselect::any_of(c("microdata", "error"))) %>%
87 | tidyr::unnest(cols = c(error_message))
88 |
89 | if (nrow(errors) > 0) {
90 | warning(sprintf("No se pudo descargar la base de year %s, type %s.
91 | Mensaje: %s
92 |
93 | ", errors$year, errors$type, errors$error_message))
94 | }
95 |
96 | df <- df %>%
97 | dplyr::select(-tidyselect::any_of(c("error")))
98 |
99 | if (!is.null(destfile) & !destfile_exists) {
100 | saveRDS(df, file = destfile)
101 | }
102 | }
103 |
104 | if (nrow(df) == 1) {
105 | return(df$microdata[[1]])
106 | } else {
107 | df %>%
108 | tidyr::unnest(microdata) %>%
109 | dplyr::select(-tidyselect::any_of(c("year", "type")))
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/R/get_total_urbano_internal.R:
--------------------------------------------------------------------------------
1 | #' Descarga de Bases de EPH total urbano
2 | #'
3 | #' @param year un integer a partir de 2016
4 | #' @param type tipo de base a descargar: 'individual' ; 'hogar'
5 | #' @param vars variables a seleccionar. Default trae todas las variables
6 | #'
7 | #' @noRd
8 |
9 | get_total_urbano_internal <- function(year = 2016,
10 | type = "individual",
11 | vars = "all") {
12 | if (!is.numeric(year)) {
13 | cli::cli_abort(c(
14 | "El argumento year debe ser numeric"
15 | ))
16 | }
17 | if (year < 2016) {
18 | cli::cli_alert_warning(c(
19 | "La funcion puede descargar bases publicadas desde 2016."
20 | ))
21 | }
22 | if (!type %in% c("individual", "hogar")) {
23 | cli::cli_abort(c(
24 | "Elegir alguna de las opciones de type: 'individual' u 'hogar'."
25 | ))
26 | }
27 |
28 | if (year < 2016) {
29 | cli::cli_abort(c(
30 | "El anio elegido no es valido",
31 | "i" = "Hay datos disponibles desde 2016"
32 | ))
33 | }
34 |
35 | link <- sprintf("https://www.indec.gob.ar/ftp/cuadros/menusuperior/eahu/EPH_Tot_Urbano_3T_%s.zip", year)
36 |
37 | temp <- tempfile(pattern = sprintf("microdatos_%s", year))
38 |
39 | try(check <- utils::download.file(link, temp), silent = TRUE)
40 | if (rlang::is_empty(check)) {
41 | cli::cli_abort(c(
42 | sprintf("Problema con la descarga %s. Puede deberse a que la base solicitada no exista.", year)
43 | ))
44 | }
45 |
46 | nombres <- NA
47 | try(nombres <- purrr::as_vector(utils::unzip(temp, list = TRUE)["Name"]), silent = TRUE)
48 | if (all(is.na(nombres))) {
49 | cli::cli_abort(c(
50 | sprintf("Problema con la descarga %s. Puede deberse a que la base solicitada no exista.", year)
51 | ))
52 | }
53 |
54 | base_hogar_name <- nombres[grep("hog", nombres, ignore.case = TRUE)]
55 | base_individual_name <- nombres[grep("pers", nombres, ignore.case = TRUE)]
56 |
57 | if (type == "individual") {
58 | base <- utils::read.table(unz(temp, base_individual_name), sep = ";", dec = ",", header = TRUE, fill = TRUE, colClasses = c(PP3F_TOT = "character", IPCF = "character", CH16_COD = "character", CH15_COD = "character")) %>%
59 | tidyr::as_tibble()
60 | }
61 | if (type == "hogar") {
62 | base <- utils::read.table(unz(temp, base_hogar_name), sep = ";", dec = ",", header = TRUE, fill = TRUE) %>%
63 | tidyr::as_tibble()
64 | }
65 |
66 | unlink(temp)
67 |
68 | if (all(vars == "all")) {
69 | base <- base %>%
70 | dplyr::rename_all(toupper)
71 |
72 | return(base)
73 | }
74 | if (nrow(base) > 0) {
75 | chequeo <- vars %in% colnames(base)
76 |
77 | if (!all(chequeo)) {
78 | cli::cli_abort(sprintf("Las variables: %s no se encuentran disponibles para esta base.
79 | Puede deberse a que son variables de la base individual (hogar) y se quiere descargar la base hogar (individual)", sub(",([^,]*)$", " y\\1", paste0(vars[!chequeo], collapse = ", "))))
80 | }
81 |
82 | base <- base %>%
83 | dplyr::rename_all(toupper) %>%
84 | dplyr::select(tidyselect::all_of(vars))
85 |
86 | return(base)
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/R/is_in_github.R:
--------------------------------------------------------------------------------
1 | #' Check if file is in github repo
2 | #'
3 | #' @param year el parametro de get_microdata_internal
4 | #' @param period el parametro de get_microdata_internal
5 | #' @param type el parametro de get_microdata_internal
6 | #'
7 | #'
8 | #' @noRd
9 | is_in_github <- function(year = 2018,
10 | period = 1,
11 | type = "individual") {
12 | if (year < 2023) {
13 | result <- TRUE
14 | # esto es porque todas las bases de la EPH hasta 2022 estan en github
15 | } else {
16 |
17 | # old version #
18 | # pg <- xml2::read_html(sprintf('https://github.com/holatam/data/tree/master/eph/%s',type))
19 |
20 | # filelist <- rvest::html_nodes(pg, "a") %>%
21 | # rvest::html_attr(name = "href" ) %>%
22 | # stringr::str_match('.*RDS') %>%
23 | # stats::na.omit()
24 | # looking_for <-sprintf('/holatam/data/blob/master/eph/%s/base_%s_%sT%s.RDS',type,type,year,period)
25 | # result <- looking_for %in% filelist[,1]
26 |
27 | result <- tryCatch(
28 | {
29 | req <- httr::GET("https://api.github.com/repos/holatam/data/git/trees/master?recursive=1")
30 |
31 | filelist <- unlist(lapply(httr::content(req)$tree, "[", "path"), use.names = FALSE)
32 |
33 | looking_for <- sprintf("eph/%s/base_%s_%sT%s.RDS", type, type, year, period)
34 |
35 | result <- looking_for %in% filelist
36 | },
37 | error = function(err) {
38 | FALSE
39 | }
40 | )
41 | }
42 |
43 | result
44 | }
45 |
--------------------------------------------------------------------------------
/R/map_agglomerates.R:
--------------------------------------------------------------------------------
1 | #' Mapa de indicadores por aglomerado
2 | #'
3 | #' @param .data Dataframe con los datos
4 | #' @param agglomerates Variable con los codigos de aglomerados
5 | #' @param indicator Variable con los indicadores
6 | #' @param alpha Opacidad de los puntos
7 | #' @param palette Paleta de colores a utilizar, incluye "viridis", "magma", "inferno", or "plasma". Para mas opciones, ver \link[leaflet]{colorNumeric}
8 | #'
9 | #' @return Devuelve un mapa de indicadores por aglomerado
10 | #'
11 | #' @examples
12 | #'
13 | #' toybase_individual_2016_04 %>%
14 | #' dplyr::group_by(AGLOMERADO) %>%
15 | #' dplyr::summarise(tasa_actividad = sum(PONDERA[ESTADO == 1]) / sum(PONDERA)) %>%
16 | #' map_agglomerates(
17 | #' agglomerates = AGLOMERADO,
18 | #' indicator = tasa_actividad
19 | #' )
20 | #' @export
21 |
22 | map_agglomerates <- function(.data, agglomerates, indicator, alpha = .75, palette = "viridis") {
23 | agglomerates <- rlang::enquo(agglomerates)
24 | indicator <- rlang::enquo(indicator)
25 |
26 | df <- .data %>%
27 | dplyr::select("AGLOMERADO" = !!agglomerates, "indicator" = !!indicator) %>%
28 | dplyr::left_join(centroides_aglomerados, by = "AGLOMERADO")
29 |
30 | pal <- leaflet::colorNumeric(
31 | palette = palette,
32 | domain = df$indicator
33 | )
34 |
35 |
36 | labs <- purrr::pmap(list(df$nombre_aglomerado, round(df$indicator, digits = 2)), function(.x, .y) paste0("", .x, "
", dplyr::as_label(indicator), ": ", .y, "
"))
37 |
38 | leaflet::leaflet(df) %>%
39 | leaflet::addTiles() %>%
40 | #leaflet::addProviderTiles(leaflet::providers$Wikimedia) %>%
41 | leaflet::addCircleMarkers(
42 | fillColor = ~ pal(indicator),
43 | fillOpacity = alpha,
44 | stroke = FALSE,
45 | label = lapply(labs, htmltools::HTML)
46 | ) %>%
47 | leaflet::addLegend("bottomright",
48 | pal = pal, values = ~indicator,
49 | title = sprintf("%s", dplyr::as_label(indicator)),
50 | opacity = 1
51 | )
52 | }
53 |
--------------------------------------------------------------------------------
/R/organize_caes.R:
--------------------------------------------------------------------------------
1 | #' @title Clasificador de Actividades
2 | #' @description Funcion para clasificar las actividades economicas segun el
3 | #' Clasificador de actividades economicas para encuestas sociodemograficas.
4 | #' CAES Mercosur 1.0 y CAES Mercosur.
5 | #' Basado en https://www.indec.gob.ar/ftp/cuadros/menusuperior/clasificadores/notas_explicativas_caes_v2018.pdf
6 | #'
7 | #' @param base Base individual de uno o mas periodos
8 | #'
9 | #' @return Devuelve la base con 8 columnas nuevas (ver `caes`)
10 | #'
11 | #' @details disclaimer: El script no es un producto oficial de INDEC.
12 | #'
13 | #' No olvides contemplar los cambios en la codificacion y categorias de las distintas versiones del clasificador CAES para la elaboracion de series de largo plazo.
14 | #' @export
15 | #'
16 | #' @examples
17 | #' bases <- dplyr::bind_rows(toybase_individual_2016_03, toybase_individual_2016_04)
18 | #' bases_clasificadas <- organize_caes(base = bases)
19 | #'
20 | organize_caes <- function(base) {
21 | if ("PP04B_CAES" %in% names(base)) {
22 | warning("Creando nueva variable PP04B_COD como copia de PP04B_CAES por compatibilidad.")
23 | base <- base %>%
24 | dplyr::mutate(PP04B_COD = dplyr::case_when(
25 | ANO4 %in% 2011:2015 ~ PP04B_CAES,
26 | TRUE ~ PP04B_COD
27 | ))
28 | }
29 |
30 | warning("Convirtiendo PP04B_COD a character")
31 | base <- base %>%
32 | dplyr::mutate(
33 | PP04B_COD = as.character(PP04B_COD),
34 | PP04B_COD = dplyr::case_when(
35 | nchar(PP04B_COD) == 1 ~ paste0("0", PP04B_COD),
36 | nchar(PP04B_COD) == 2 ~ PP04B_COD,
37 | nchar(PP04B_COD) == 3 ~ paste0("0", PP04B_COD),
38 | nchar(PP04B_COD) == 4 ~ PP04B_COD
39 | ),
40 | caes_version = dplyr::case_when(
41 | ANO4 >= 2011 ~ "1.0",
42 | ANO4 < 2011 ~ "0"
43 | )
44 | )
45 |
46 | base <- base %>%
47 | dplyr::left_join(caes, by = c("PP04B_COD", "caes_version"))
48 |
49 | if (any(base$ANO4 < 2011) & any(base$ANO4 >= 2011)) {
50 | warning("Para los datos anteriores a 2011 se aplico la clasificacion CAES v.0 y para los de 2011 en adelante la clasificacion CAES v.1.0")
51 | }
52 | return(base)
53 | }
54 |
--------------------------------------------------------------------------------
/R/organize_cno.R:
--------------------------------------------------------------------------------
1 | #' Clasificador de Ocupaciones
2 | #' @description
3 | #' Funcion para clasificar las ocupaciones segun las 4 dimensiones del Clasificador Nacional de Ocupaciones
4 | #' (CNO 2001)
5 | #' @param base Base individual de uno o mas periodos
6 | #'
7 | #' @return Devuelve la base con 4 columnas nuevas (que indican la informacion correspondiente al Clasificador Nacional de Ocupaciones)
8 | #'
9 | #' @details
10 | #' Importante: Verificar que el clasificador CNO 2001 sea compatible con la base que estes utilizando.
11 | #'
12 | #' disclaimer: El script no es un producto oficial de INDEC.
13 | #'
14 | #' @examples
15 | #'
16 | #'
17 | #' bases <- dplyr::bind_rows(toybase_individual_2016_03, toybase_individual_2016_04)
18 | #' bases_clasificadas <- organize_cno(base = bases)
19 | #'
20 | #' @export
21 | organize_cno <- function(base) {
22 | ## Estos 4 df quizas podrian ir como RDA guardados en vez de CNO
23 | ## que, si bien condensa toda la info, esta en un formato que mucho no ayuda
24 | ## La otra opcion es definir las categorias a mano con case_when
25 |
26 | caracter <- CNO %>%
27 | dplyr::filter(digit == 12) %>%
28 | dplyr::select(value, CATEGORIA = label) %>%
29 | dplyr::add_row(value = "99", CATEGORIA = "Ns.Nc")
30 |
31 | jerarquia <- CNO %>%
32 | dplyr::filter(digit == 3) %>%
33 | dplyr::select(value, JERARQUIA = label) %>%
34 | dplyr::add_row(value = "9", JERARQUIA = "Ns.Nc")
35 |
36 | tecnologia <- CNO %>%
37 | dplyr::filter(digit == 4) %>%
38 | dplyr::select(value, TECNOLOGIA = label) %>%
39 | dplyr::add_row(value = "9", TECNOLOGIA = "Ns.Nc")
40 |
41 | calificacion <- CNO %>%
42 | dplyr::filter(digit == 5) %>%
43 | dplyr::select(value, CALIFICACION = label) %>%
44 | dplyr::add_row(value = c("6", "7", "8", "9"), CALIFICACION = c("mal codificado", "falta informacion", "otro", "Ns.Nc"))
45 |
46 | base <- base %>%
47 | dplyr::mutate(
48 | PP04D_COD = as.character(PP04D_COD),
49 | CLASIF_CNO = stringr::str_pad(PP04D_COD, 5, side = "left", pad = "0"),
50 | DIGIT12 = substr(CLASIF_CNO, 1, 2),
51 | DIGIT3 = substr(CLASIF_CNO, 3, 3),
52 | DIGIT4 = substr(CLASIF_CNO, 4, 4),
53 | DIGIT5 = substr(CLASIF_CNO, 5, 5)
54 | ) %>%
55 | dplyr::left_join(., caracter,
56 | by = c("DIGIT12" = "value")
57 | ) %>%
58 | dplyr::left_join(., jerarquia,
59 | by = c("DIGIT3" = "value")
60 | ) %>%
61 | dplyr::left_join(., tecnologia,
62 | by = c("DIGIT4" = "value")
63 | ) %>%
64 | dplyr::left_join(., calificacion,
65 | by = c("DIGIT5" = "value")
66 | ) %>%
67 | dplyr::select(-tidyselect::any_of(c("CLASIF_CNO", "DIGIT12", "DIGIT3", "DIGIT4", "DIGIT5")))
68 |
69 |
70 |
71 | return(base)
72 | }
73 |
--------------------------------------------------------------------------------
/R/organize_panels.R:
--------------------------------------------------------------------------------
1 | #' Pool de Datos en Panel - Base Individudal EPH continua
2 | #'
3 | #' Permite armar un pool de datos en panel de la EPH continua a partir
4 | #' de especificar una serie consecutiva de bases, variables y el largo de la ventana -window- de observacion
5 | #'
6 | #' @param bases Lista de bases de microdatos a utilizar para armar el pool de datos
7 | #' @param variables Vector con nombres de las variables de interes
8 | #' @param window Especificar distancia temporal entre las observaciones. anual o trimestral
9 | #' @details
10 | #' disclaimer: El script no es un producto oficial de INDEC.
11 | #' @return Devuelve el pool de datos de panel
12 | #' @export
13 | #'
14 | #' @examples
15 | #'
16 | #' lista_bases <- list(toybase_individual_2016_03, toybase_individual_2016_04)
17 | #' pool_trimestral <- organize_panels(
18 | #' bases = lista_bases,
19 | #' variables = c("P21", "ESTADO"),
20 | #' window = "trimestral"
21 | #' )
22 | organize_panels <- function(bases, variables, window = "anual") {
23 | if (!is.list(bases)) {
24 | cli::cli_abort(c(
25 | "El argumento bases requiere un objeto de tipo lista."
26 | ))
27 | }
28 | if (!window %in% c("anual", "trimestral")) {
29 | cli::cli_abort(c(
30 | "Elegir alguna de las opciones de window: 'anual' u 'trimestral'."
31 | ))
32 | }
33 |
34 | bases_continua <- dplyr::bind_rows(bases) %>%
35 | dplyr::select(tidyselect::all_of(c("CODUSU", "NRO_HOGAR", "COMPONENTE",
36 | "ANO4", "TRIMESTRE", "CH04", "CH06", variables))) %>%
37 | dplyr::filter(ESTADO != 0) %>%
38 | dplyr::mutate(Periodo = zoo::as.yearqtr(paste0(ANO4, " Q", TRIMESTRE)))
39 |
40 | ## Creo una Replica de la base, y le agrego (_t1) al nombre de cada
41 | ## variable, excepto a las que voy a usar para "matchear".
42 | Teuno <- function(x) {
43 | paste0(x, "_t1")
44 | }
45 |
46 | ## En Base a la amplitud del panel que especificare al correr en la funcion resto en la Base
47 | ## Replica el identificador de Trimestre construido, para hacer un join con la Base.
48 |
49 | bases_continua_join <- bases_continua %>%
50 | dplyr::rename_at(dplyr::vars(-c(1:3, ncol(.))), Teuno) %>%
51 | dplyr::mutate(Periodo = dplyr::case_when(
52 | window == "anual" ~ Periodo - 1,
53 | window == "trimestral" ~ Periodo - 0.25
54 | ))
55 |
56 | panel_continua <- dplyr::inner_join(bases_continua,
57 | bases_continua_join,
58 | by = c("CODUSU", "NRO_HOGAR", "COMPONENTE", "Periodo")
59 | ) %>%
60 | dplyr::mutate(consistencia = dplyr::case_when(
61 | abs(CH06_t1 - CH06) > 2 |
62 | CH04 != CH04_t1 ~ FALSE,
63 | TRUE ~ TRUE
64 | ))
65 |
66 | consistencias_continua <- panel_continua %>%
67 | dplyr::group_by(Periodo) %>%
68 | dplyr::summarise(
69 | sin_controles = dplyr::n(),
70 | con_controles = sum(consistencia, na.rm = TRUE),
71 | perdida = 1 - (con_controles / sin_controles)
72 | )
73 |
74 | return(panel_continua)
75 | }
76 |
--------------------------------------------------------------------------------
/R/python/epyh.py:
--------------------------------------------------------------------------------
1 | import requests, zipfile, io
2 | import pandas as pd
3 | import json
4 |
5 | def epyh(anio = 2018, trimestre = 2,individual = False):
6 |
7 | url = 'https://www.indec.gob.ar/ftp/cuadros/menusuperior/eph/EPH_usu_'+str(trimestre)+'_Trim_'+str(anio)+'_txt.zip'
8 |
9 | #decarga zip
10 | r = requests.get(url)
11 | z = zipfile.ZipFile(io.BytesIO(r.content))
12 |
13 | if individual:
14 | nombre_archivo = 'usu_individual_t'+str(trimestre)+str(anio)[2:]+'.txt'
15 | etiquetas = json.load(open("eph/diccionario_individual.txt"))
16 |
17 | else:
18 | nombre_archivo = 'usu_hogar_t'+str(trimestre)+str(anio)[2:]+'.txt'
19 | etiquetas = json.load(open("eph/diccionario_hogar.txt"))
20 |
21 | #leer datos
22 | dt = pd.read_csv(z.open(nombre_archivo),sep=';',dtype=str)
23 | #etiquetar
24 | dt = dt.replace(etiquetas)
25 | return dt
26 |
27 | dt = epyh(anio = 2018, trimestre = 2,individual = False)
28 | dt.head()
29 |
--------------------------------------------------------------------------------
/R/utils-pipe.R:
--------------------------------------------------------------------------------
1 | #' Pipe operator
2 | #'
3 | #' @name %>%
4 | #' @rdname pipe
5 | #' @keywords internal
6 | #' @export
7 | #' @importFrom dplyr %>%
8 | #' @usage lhs \%>\% rhs
9 | NULL
10 |
--------------------------------------------------------------------------------
/README.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | output: github_document
3 | ---
4 |
5 |
6 |
7 | ```{r, include = FALSE}
8 | knitr::opts_chunk$set(
9 | collapse = TRUE,
10 | warning = FALSE,
11 | comment = "#>",
12 | fig.path = "man/figures/README-",
13 | out.width = "100%"
14 | )
15 | ```
16 |
17 | # eph
18 |
19 |
20 | [](https://github.com/ropensci/eph/actions)
21 | [](https://app.codecov.io/gh/holatam/eph?branch=master)
23 | [](https://cran.r-project.org/package=eph)
24 | [](https://cran.r-project.org/package=eph)
25 | [](https://cran.r-project.org/package=eph)
26 | [](https://doi.org/10.5281/zenodo.8352221)
27 |
28 |
29 |
30 |
31 | # Caja de Herramientas para el procesamiento de la Encuesta Permanente de Hogares
32 |
33 | ## Descripción
34 |
35 | Si querés procesar datos de la [Encuesta Permanente de Hogares (EPH) elaborada por el Instituto Nacional de Estadística y Censos de la República Argentina (INDEC)](https://www.indec.gob.ar/bases-de-datos.asp) mediante el lenguaje de programación [R](https://www.r-project.org/), la librería `eph` tiene por objeto facilitar tu trabajo.
36 |
37 | El paquete cumple un rol fundamental en la democratización de la posibilidad de procesar los datos publicados por INDEC y así obtener conclusiones independientes de aquellas publicadas en los informes elaborados por el organismo. Dado que la información de la EPH constituye una de las principales fuentes para el análisis de las problemáticas sociales presentes en Argentina, el paquete no sólo posibilita investigaciones académicas y periodísticas, sino que también contribuye a la formulación de políticas públicas fundamentadas en evidencia.
38 |
39 |
40 | Algunas de sus funciones son:
41 |
42 | - **`get_microdata()`**: Descarga las bases de microdatos,
43 |
44 | - **`organize_panels()`**: Permite armar un pool de datos en panel de la EPH continua,
45 |
46 | - **`organize_cno()`**: Clasifica las ocupaciones según el Clasificador Nacional de Ocupaciones (CNO) 2001
47 |
48 | - **`organize_caes()`**: Clasifica las actividades económicas según el Clasificador de Actividades Economicas para encuestas Sociodemograficas (CAES) Mercosur 1.0 y el CAES Mercosur
49 |
50 | - **`organize_labels()`**: Etiqueta las bases siguiendo el último [diseño de registro](https://www.indec.gob.ar/ftp/cuadros/menusuperior/eph/EPH_registro_t218.pdf)
51 |
52 | - **`map_agglomerates()`**: Mapa de indicadores por aglomerado
53 |
54 |
55 | El paquete también cuenta con dataframes útiles para el trabajo con la EPH. Algunos de estos son:
56 |
57 | - **`diccionario_regiones`**: Diccionario de regiones según el diseño de registro de la EPH
58 |
59 | - **`diccionario_aglomerados`**: Diccionario de aglomerados según el diseño de registro de la EPH
60 |
61 | - **`centroides_aglomerados`**: Tabla de centroides de los aglomerados (basado en https://www.indec.gob.ar/indec/web/Nivel4-Tema-1-39-120)
62 |
63 | - **`adulto_equivalente`**: Tabla de valores de adulto equivalente segun sexo y edad ([ver definición mtodológica](https://www.indec.gob.ar/ftp/cuadros/sociedad/preguntas_frecuentes_cba_cbt.pdf))
64 |
65 | ## Instalación
66 |
67 |
68 | Para descargar la versión estable desde CRAN:
69 |
70 | ```{r, eval = FALSE}
71 | install.packages("eph")
72 | ```
73 |
74 | Para descargar desde R-universe:
75 |
76 | ```{r, eval = FALSE}
77 | install.packages("eph", repos = "https://ropensci.r-universe.dev")
78 | ```
79 |
80 |
81 | Para la versión en desarrollo:
82 |
83 | ```{r, eval = FALSE}
84 | # install.packages('devtools')
85 | # si no tiene instalado devtools
86 |
87 | devtools::install_github("holatam/eph")
88 | ```
89 |
90 | ## Modo de uso
91 |
92 | Ejemplo de descarga de microdatos
93 |
94 | ```{r}
95 | # Cargo la libreria
96 | library(eph)
97 |
98 | base_individual <- get_microdata(
99 | year = 2018:2019, # especifco el año
100 | trimester = 1, # el trimestre
101 | type = "individual", # y el tipo de base
102 | vars = c("PONDERA", "ESTADO", "CAT_OCUP")
103 | ) # opcionalmente, puedo especificar las variables que deseo utilizar.
104 |
105 | base_individual
106 | ```
107 |
108 | ## Cómo citar este paquete
109 |
110 | Podés citar este paquete como "se obtuvieron y/o normalizaron los datos de la Encuesta Permanente de Hogares (EPH-INDEC) utilizando el paquete de R 'eph' (Kozlowski et al, 2020)".
111 |
112 | La referencia completa para incluir en la bibliografía es:
113 |
114 | ```
115 | Carolina Pradier, Guido Weksler, Pablo Tiscornia, Natsumi Shokida, Germán Rosati, & Diego Kozlowski. (2023). ropensci/eph V1.0.0 (1.0.0). Zenodo. https://doi.org/10.5281/zenodo.8352221
116 | ```
117 |
118 | Si necesitás la entrada bib:
119 |
120 | ```bib
121 |
122 | @software{carolina_pradier_2023_8352221,
123 | author = {Carolina Pradier and
124 | Guido Weksler and
125 | Pablo Tiscornia and
126 | Natsumi Shokida and
127 | Germán Rosati and
128 | Diego Kozlowski},
129 | title = {ropensci/eph V1.0.0},
130 | month = sep,
131 | year = 2023,
132 | publisher = {Zenodo},
133 | version = {1.0.0},
134 | doi = {10.5281/zenodo.8352221},
135 | url = {https://doi.org/10.5281/zenodo.8352221}
136 | }
137 |
138 | ```
139 |
140 |
141 | ## Aportes de la comunidad
142 |
143 | Este paquete se propone incorporar cualquier función de propósitos generales que utilice como base los datos de la Encuesta Permanente de Hogares. Todos los aportes en este sentido son bienvenidos.
144 |
145 | Si trabajas con la EPH y querés agregar tu función, te recomendamos que leas los siguientes [consejos](https://github.com/ropensci/eph/blob/master/docs/CONTRIBUTING.md) sobre cómo como colaborar
146 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # eph
5 |
6 |
7 |
8 | [](https://github.com/ropensci/eph/actions)
10 | [](https://app.codecov.io/gh/holatam/eph?branch=master)
12 | [](https://cran.r-project.org/package=eph)
14 | [](https://cran.r-project.org/package=eph)
15 | [](https://cran.r-project.org/package=eph)
16 | [](https://doi.org/10.5281/zenodo.8352221)
17 |
18 |
19 |
20 | # Caja de Herramientas para el procesamiento de la Encuesta Permanente de Hogares
21 |
22 | ## Descripción
23 |
24 | Si querés procesar datos de la [Encuesta Permanente de Hogares (EPH)
25 | elaborada por el Instituto Nacional de Estadística y Censos de la
26 | República Argentina
27 | (INDEC)](https://www.indec.gob.ar/bases-de-datos.asp) mediante el
28 | lenguaje de programación [R](https://www.r-project.org/), la librería
29 | `eph` tiene por objeto facilitar tu trabajo.
30 |
31 | El paquete cumple un rol fundamental en la democratización de la
32 | posibilidad de procesar los datos publicados por INDEC y así obtener
33 | conclusiones independientes de aquellas publicadas en los informes
34 | elaborados por el organismo. Dado que la información de la EPH
35 | constituye una de las principales fuentes para el análisis de las
36 | problemáticas sociales presentes en Argentina, el paquete no sólo
37 | posibilita investigaciones académicas y periodísticas, sino que también
38 | contribuye a la formulación de políticas públicas fundamentadas en
39 | evidencia.
40 |
41 | Algunas de sus funciones son:
42 |
43 | - **`get_microdata()`**: Descarga las bases de microdatos,
44 |
45 | - **`organize_panels()`**: Permite armar un pool de datos en panel de la
46 | EPH continua,
47 |
48 | - **`organize_cno()`**: Clasifica las ocupaciones según el Clasificador
49 | Nacional de Ocupaciones (CNO) 2001
50 |
51 | - **`organize_caes()`**: Clasifica las actividades económicas según el
52 | Clasificador de Actividades Economicas para encuestas
53 | Sociodemograficas (CAES) Mercosur 1.0 y el CAES Mercosur
54 |
55 | - **`organize_labels()`**: Etiqueta las bases siguiendo el último
56 | [diseño de
57 | registro](https://www.indec.gob.ar/ftp/cuadros/menusuperior/eph/EPH_registro_t218.pdf)
58 |
59 | - **`map_agglomerates()`**: Mapa de indicadores por aglomerado
60 |
61 | El paquete también cuenta con dataframes útiles para el trabajo con la
62 | EPH. Algunos de estos son:
63 |
64 | - **`diccionario_regiones`**: Diccionario de regiones según el diseño de
65 | registro de la EPH
66 |
67 | - **`diccionario_aglomerados`**: Diccionario de aglomerados según el
68 | diseño de registro de la EPH
69 |
70 | - **`centroides_aglomerados`**: Tabla de centroides de los aglomerados
71 | (basado en )
72 |
73 | - **`adulto_equivalente`**: Tabla de valores de adulto equivalente segun
74 | sexo y edad ([ver definición
75 | mtodológica](https://www.indec.gob.ar/ftp/cuadros/sociedad/preguntas_frecuentes_cba_cbt.pdf))
76 |
77 | ## Instalación
78 |
79 | Para descargar la versión estable desde CRAN:
80 |
81 | ``` r
82 | install.packages("eph")
83 | ```
84 |
85 | Para descargar desde R-universe:
86 |
87 | ``` r
88 | install.packages("eph", repos = "https://ropensci.r-universe.dev")
89 | ```
90 |
91 | Para la versión en desarrollo:
92 |
93 | ``` r
94 | # install.packages('devtools')
95 | # si no tiene instalado devtools
96 |
97 | devtools::install_github("holatam/eph")
98 | ```
99 |
100 | ## Modo de uso
101 |
102 | Ejemplo de descarga de microdatos
103 |
104 | ``` r
105 | # Cargo la libreria
106 | library(eph)
107 |
108 | base_individual <- get_microdata(
109 | year = 2018:2019, # especifco el año
110 | trimester = 1, # el trimestre
111 | type = "individual", # y el tipo de base
112 | vars = c("PONDERA", "ESTADO", "CAT_OCUP")
113 | ) # opcionalmente, puedo especificar las variables que deseo utilizar.
114 |
115 | base_individual
116 | #> # A tibble: 117,320 × 3
117 | #> PONDERA ESTADO CAT_OCUP
118 | #>
119 | #> 1 684 4 0
120 | #> 2 1008 3 0
121 | #> 3 1008 1 1
122 | #> 4 1008 2 0
123 | #> 5 886 1 2
124 | #> 6 594 3 0
125 | #> 7 594 3 0
126 | #> 8 546 3 0
127 | #> 9 509 1 3
128 | #> 10 509 1 3
129 | #> # ℹ 117,310 more rows
130 | ```
131 |
132 | ## Cómo citar este paquete
133 |
134 | Podés citar este paquete como “se obtuvieron y/o normalizaron los datos
135 | de la Encuesta Permanente de Hogares (EPH-INDEC) utilizando el paquete
136 | de R ‘eph’ (Kozlowski et al, 2020)”.
137 |
138 | La referencia completa para incluir en la bibliografía es:
139 |
140 | Carolina Pradier, Guido Weksler, Pablo Tiscornia, Natsumi Shokida, Germán Rosati, & Diego Kozlowski. (2023). ropensci/eph V1.0.0 (1.0.0). Zenodo. https://doi.org/10.5281/zenodo.8352221
141 |
142 | Si necesitás la entrada bib:
143 |
144 | ``` bib
145 |
146 | @software{carolina_pradier_2023_8352221,
147 | author = {Carolina Pradier and
148 | Guido Weksler and
149 | Pablo Tiscornia and
150 | Natsumi Shokida and
151 | Germán Rosati and
152 | Diego Kozlowski},
153 | title = {ropensci/eph V1.0.0},
154 | month = sep,
155 | year = 2023,
156 | publisher = {Zenodo},
157 | version = {1.0.0},
158 | doi = {10.5281/zenodo.8352221},
159 | url = {https://doi.org/10.5281/zenodo.8352221}
160 | }
161 |
162 | ```
163 |
164 | ## Aportes de la comunidad
165 |
166 | Este paquete se propone incorporar cualquier función de propósitos
167 | generales que utilice como base los datos de la Encuesta Permanente de
168 | Hogares. Todos los aportes en este sentido son bienvenidos.
169 |
170 | Si trabajas con la EPH y querés agregar tu función, te recomendamos que
171 | leas los siguientes
172 | [consejos](https://github.com/ropensci/eph/blob/master/docs/CONTRIBUTING.md)
173 | sobre cómo como colaborar
174 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | comment: false
2 |
3 | coverage:
4 | status:
5 | project:
6 | default:
7 | target: auto
8 | threshold: 1%
9 | patch:
10 | default:
11 | target: auto
12 | threshold: 1%
13 |
--------------------------------------------------------------------------------
/data-raw/.Rhistory:
--------------------------------------------------------------------------------
1 | devtools::install_github("holatam/eph")
2 | library(eph)
3 | cuadritos.caes <- eph::caes
4 | cuadros.caes.v0.v1 <- eph::caes
5 | bases <- get_microdata(year = 2009:2012,trimester = 1:4)
6 | bases.anidadas <- bases %>%
7 | select(microdata) %>%
8 | unnest(cols = microdata)
9 | library(tidyverse)
10 | bases.anidadas <- bases %>%
11 | select(microdata) %>%
12 | unnest(cols = microdata)
13 | bases_clasificadas <- bases.anidadas %>%
14 | organize_caes()
15 | View(bases_clasificadas)
16 |
--------------------------------------------------------------------------------
/data-raw/aglomerados_geo.R:
--------------------------------------------------------------------------------
1 | library(sf)
2 | library(tidyverse)
3 |
4 | aglos <- sf::st_read("../data/eph/georef/aglomerados_eph.json")
5 | # entidades <- sf::st_read('../data/eph/georef/entidades_eph.json')
6 | # radios <- sf::st_read('../data/eph/georef/radios_eph.json')
7 |
8 |
9 | centroides_aglomerados <- aglos %>%
10 | filter(!st_is_empty(geometry)) %>%
11 | group_by(eph_codagl) %>%
12 | summarise(
13 | AGLOMERADO = as.integer(paste(unique(eph_codagl))),
14 | nombre_aglomerado = unique(eph_aglome)[1]
15 | ) %>%
16 | st_centroid() %>%
17 | select(AGLOMERADO, nombre_aglomerado, geometry)
18 |
19 | # ggplot() +
20 | # geom_sf(data = centroides_aglomerados )
21 |
22 |
23 | centroides_aglomerados <- centroides_aglomerados %>% st_transform("+proj=longlat +datum=WGS84")
24 |
25 | # remove geometry because of incompatibility with dplyr 1.0
26 | centroides_aglomerados <- centroides_aglomerados %>%
27 | bind_cols(
28 | sf::st_coordinates(centroides_aglomerados) %>%
29 | as_tibble() %>%
30 | rename(lon = X, lat = Y)
31 | ) %>%
32 | as_tibble() %>%
33 | select(-geometry)
34 |
35 | usethis::use_data(centroides_aglomerados, overwrite = TRUE)
36 |
37 |
38 | data_frame_roxygen <- function(obj) {
39 | if (inherits(obj, c("data.frame", "tibble"))) {
40 | cl <- vapply(obj, FUN = typeof, FUN.VALUE = character(1))
41 |
42 | items <- paste0(sprintf("#' \\item{\\code{%s}}{%s ---DESCRIPTION---}", names(cl), cl))
43 |
44 |
45 | items <- paste0(items, collapse = "\n")
46 |
47 |
48 | header <- c(
49 | title = paste0("#' @title ", deparse(substitute(obj))),
50 | description = "#' @description ---COLUMN DESCRIPTION---",
51 | format = sprintf("#' @format A data frame with %s rows and %s variables:", nrow(obj), length(cl))
52 | )
53 |
54 | ret <- sprintf(
55 | "%s\n%s\n%s",
56 | paste(header, collapse = "\n"),
57 | sprintf("#' \\describe{\n%s \n#'}", items),
58 | sprintf('\n"%s"', deparse(substitute(obj)))
59 | )
60 | }
61 | ret
62 | }
63 |
64 |
65 | data_frame_roxygen(centroides_aglomerados)
66 |
--------------------------------------------------------------------------------
/data/CNO.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/CNO.rda
--------------------------------------------------------------------------------
/data/adulto_equivalente.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/adulto_equivalente.rda
--------------------------------------------------------------------------------
/data/caes.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/caes.rda
--------------------------------------------------------------------------------
/data/canastas_reg_example.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/canastas_reg_example.rda
--------------------------------------------------------------------------------
/data/centroides_aglomerados.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/centroides_aglomerados.rda
--------------------------------------------------------------------------------
/data/diccionario_aglomerados.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/diccionario_aglomerados.rda
--------------------------------------------------------------------------------
/data/diccionario_regiones.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/diccionario_regiones.rda
--------------------------------------------------------------------------------
/data/errores_muestrales.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/errores_muestrales.rda
--------------------------------------------------------------------------------
/data/toybase_hogar_2016_04.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/toybase_hogar_2016_04.rda
--------------------------------------------------------------------------------
/data/toybase_individual_2016_03.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/toybase_individual_2016_03.rda
--------------------------------------------------------------------------------
/data/toybase_individual_2016_04.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/data/toybase_individual_2016_04.rda
--------------------------------------------------------------------------------
/doc/eph.R:
--------------------------------------------------------------------------------
1 | ## ----setup, include = FALSE---------------------------------------------------
2 | knitr::opts_chunk$set(
3 | collapse = TRUE,
4 | comment = "#>"
5 | )
6 |
7 | ## ----message=FALSE, warning=FALSE---------------------------------------------
8 | library(eph)
9 | library(dplyr)
10 | library(tidyr)
11 | library(purrr)
12 | library(ggplot2)
13 |
14 | ## -----------------------------------------------------------------------------
15 | ind_3_18 <- get_microdata(
16 | year = 2018,
17 | trimester = 3,
18 | type = "individual"
19 | )
20 |
21 | ## -----------------------------------------------------------------------------
22 | ind_3_18 <- organize_labels(
23 | df = ind_3_18,
24 | type = "individual"
25 | )
26 |
27 | ## -----------------------------------------------------------------------------
28 | hog_3_18 <- get_microdata(
29 | year = 2018,
30 | trimester = 3,
31 | type = "hogar"
32 | ) %>%
33 | organize_labels(.,
34 | type = "hogar"
35 | )
36 |
37 | ## -----------------------------------------------------------------------------
38 | calculate_tabulates(
39 | base = ind_3_18,
40 | x = "NIVEL_ED",
41 | y = "CH04",
42 | weights = "PONDERA",
43 | add.totals = "row",
44 | add.percentage = "col"
45 | )
46 |
47 | ## -----------------------------------------------------------------------------
48 | calculate_tabulates(
49 | base = ind_3_18,
50 | x = "NIVEL_ED",
51 | y = "CH04",
52 | add.totals = "row",
53 | add.percentage = "col"
54 | )
55 |
56 | ## -----------------------------------------------------------------------------
57 | ### Armo vector con el nombre de las variables de interés incluyendo
58 | # -variables necesarias para hacer el panel
59 | # -variables que nos interesan en nuestro análisis
60 | variables <- c(
61 | "CODUSU", "NRO_HOGAR", "COMPONENTE", "ANO4",
62 | "TRIMESTRE", "CH04", "CH06",
63 | "ESTADO", "PONDERA"
64 | )
65 |
66 | ### Descargo la base individual para el 2018_t1
67 | base_2018t1 <- get_microdata(
68 | year = 2018, trimester = 1, type = "individual",
69 | vars = variables
70 | )
71 |
72 | ### Descargo la base individual para el 2018_t2
73 | base_2018t2 <- get_microdata(
74 | year = 2018, trimester = 2, type = "individual",
75 | vars = variables
76 | )
77 |
78 | ### Armo el panel
79 | pool <- organize_panels(
80 | bases = list(base_2018t1, base_2018t2),
81 | variables = c("ESTADO", "PONDERA"),
82 | window = "trimestral"
83 | )
84 |
85 | ## -----------------------------------------------------------------------------
86 | pool
87 |
88 | ## ----message=FALSE, warning=FALSE---------------------------------------------
89 | pool %>%
90 | organize_labels(.) %>%
91 | calculate_tabulates(
92 | x = "ESTADO",
93 | y = "ESTADO_t1",
94 | weights = "PONDERA",
95 | add.percentage = "row"
96 | )
97 |
98 | ## ----message=FALSE, warning=FALSE---------------------------------------------
99 | df <- get_microdata(
100 | year = 2017:2019,
101 | trimester = 1:4,
102 | type = "individual",
103 | vars = c("ANO4", "TRIMESTRE", "PONDERA", "ESTADO", "CAT_OCUP")
104 | )
105 |
106 | df %>%
107 | sample_n(5)
108 |
109 | ## -----------------------------------------------------------------------------
110 | df <- df %>%
111 | group_by(ANO4, TRIMESTRE) %>%
112 | summarise(indicador = sum(PONDERA[CAT_OCUP == 3 & ESTADO == 1], na.rm = T) / sum(PONDERA[ESTADO == 1], na.rm = T))
113 |
114 | df
115 |
116 | ## -----------------------------------------------------------------------------
117 | lineas <- get_poverty_lines()
118 | lineas
119 |
120 | ## ---- fig.width=7, fig.height=5-----------------------------------------------
121 | lineas %>%
122 | select(-ICE) %>%
123 | pivot_longer(cols = c("CBA", "CBT"), names_to = "canasta", values_to = "valor") %>%
124 | ggplot() +
125 | geom_line(aes(x = periodo, y = valor, col = canasta))
126 |
127 | ## -----------------------------------------------------------------------------
128 | canastas_reg_example
129 |
130 | ## -----------------------------------------------------------------------------
131 | adulto_equivalente %>% head()
132 |
133 | ## ----warning=FALSE------------------------------------------------------------
134 | bases <- bind_rows(toybase_individual_2016_03, toybase_individual_2016_04)
135 | base_pobreza <- calculate_poverty(
136 | base = bases,
137 | basket = canastas_reg_example,
138 | print_summary = TRUE
139 | )
140 |
141 | ## -----------------------------------------------------------------------------
142 | base_pobreza %>%
143 | select(CODUSU, ITF, region, adequi_hogar, CBA_hogar, CBT_hogar, situacion) %>%
144 | sample_n(10)
145 |
146 |
--------------------------------------------------------------------------------
/docs/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Página no encontrada (404) • eph
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
32 |
33 |
34 |
35 |
36 |
37 |
94 |
95 |
98 |
99 | Contenido no encontrado. Por favor utilice los enlaces de la barra de navegación.
100 |
101 |
102 |
103 |
107 |
108 |
109 |
110 |
111 |
112 |
116 |
117 |
118 |
119 |
Sitio creado con pkgdown 2.0.7.
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/docs/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Bienvenides :tada: :tada: :tada:
2 |
3 | El objetivo de esta librería es construir un Toolbox para el procesamiento de la [Encuesta Permanente de Hogares (indec)](https://www.indec.gob.ar/bases-de-datos.asp)
4 |
5 | Para agregar tu función te pedimos que sigas los siguentes pasos:
6 |
7 | 1. Hace un fork de este repositorio
8 | 2. Agregues tu función como un archivo .R en la carpeta R/ con el mismo nombre que la función
9 | 3. Documenta la misma con [roxygen2](http://kbroman.org/pkg_primer/pages/docs.html) aclarando su funcionalidad, los parámetros y un ejemplo de uso. Para ver como se documenta poder revisar otra de las funciones en ese mismo directorio
10 | 4. Recordá que para que tu función se pueda utilizar, al final de la documentación debes agregar un
11 | `#' @export`
12 | 5. Controla que los tipos y valores de los parametros de tu función estén bien (para un ejemplo, podes mirar [get_microdata.r](https://github.com/rindec/eph/blob/master/R/get_microdata.R)) y agregá los tests que sean pertinentes.
13 | 6. Agrega las dependencias en el archivo DESCRIPTION
14 | 7. Chequea el paquete con ```devtools::check()```
15 | 8. Si todo funciona bien, entonces hace un pull request
16 |
17 | __obs.__ Te pedimos que en la medida de los posible trates de seguir la [guía de estilo del Tidyverse](https://style.tidyverse.org/syntax.html) que va a simplificar mucho la lectura del código y la usabilidad de la librería
18 |
19 |
20 | # Nombres de Funciones
21 |
22 | Para mantener la cohesión interna de la librería, decidimos el siguiente esquema de nombres para funciones:
23 |
24 | - Las mismas deben ser escritas en inglés, al igual que los parametros que utilicen.
25 | - funciones que descargan datos `get_`{microdata | poverty_lines}
26 | - funciones que calculan cosas `calculate_`{poverty | tabulates}
27 | - funciones que organizan los datos `organize_` {labels | panels}
28 | - funciones que estiman cosas `estimate_{confint}`
29 |
--------------------------------------------------------------------------------
/docs/LICENSE-text.html:
--------------------------------------------------------------------------------
1 |
2 | Licencia • eph
12 |
13 |
14 |
15 |
63 |
64 |
67 |
68 |
YEAR: 2019
69 | COPYRIGHT HOLDER: Diego Kozlowski
70 |
71 |
72 |
73 |
74 |
77 |
78 |
79 |
80 |
81 |
82 |
85 |
86 |
87 |
Sitio creado con pkgdown 2.0.7.
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/docs/LICENSE.html:
--------------------------------------------------------------------------------
1 |
2 | MIT License • eph
12 |
13 |
14 |
15 |
63 |
64 |
67 |
68 |
69 |
70 |
Copyright (c) 2019 Diego Kozlowski
71 |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
72 |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
73 |
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
74 |
75 |
76 |
77 |
78 |
81 |
82 |
83 |
84 |
85 |
86 |
89 |
90 |
91 |
Sitio creado con pkgdown 2.0.7.
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/docs/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/apple-touch-icon.png
--------------------------------------------------------------------------------
/docs/articles/eph_files/figure-html/unnamed-chunk-13-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/eph_files/figure-html/unnamed-chunk-13-1.png
--------------------------------------------------------------------------------
/docs/articles/eph_files/figure-html/unnamed-chunk-14-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/eph_files/figure-html/unnamed-chunk-14-1.png
--------------------------------------------------------------------------------
/docs/articles/eph_files/figure-html/unnamed-chunk-15-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/eph_files/figure-html/unnamed-chunk-15-1.png
--------------------------------------------------------------------------------
/docs/articles/eph_files/figure-html/unnamed-chunk-17-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/eph_files/figure-html/unnamed-chunk-17-1.png
--------------------------------------------------------------------------------
/docs/articles/eph_files/figure-html/unnamed-chunk-18-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/eph_files/figure-html/unnamed-chunk-18-1.png
--------------------------------------------------------------------------------
/docs/articles/eph_files/figure-html/unnamed-chunk-19-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/eph_files/figure-html/unnamed-chunk-19-1.png
--------------------------------------------------------------------------------
/docs/articles/eph_files/header-attrs-2.9/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-10-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-10-1.png
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-11-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-11-1.png
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-12-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-12-1.png
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-13-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-13-1.png
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-14-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-14-1.png
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-15-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-15-1.png
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-6-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-6-1.png
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-7-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-7-1.png
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-8-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-8-1.png
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-9-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/articles/estimacion_pobreza_files/figure-html/unnamed-chunk-9-1.png
--------------------------------------------------------------------------------
/docs/articles/estimacion_pobreza_files/header-attrs-2.9/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/index.html:
--------------------------------------------------------------------------------
1 |
2 | Artículos • eph
12 |
13 |
14 |
15 |
79 |
80 |
81 |
84 |
85 |
86 |
Sitio creado con pkgdown 2.0.7.
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/favicon-16x16.png
--------------------------------------------------------------------------------
/docs/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/favicon-32x32.png
--------------------------------------------------------------------------------
/docs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/favicon.ico
--------------------------------------------------------------------------------
/docs/link.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/docs/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/logo.png
--------------------------------------------------------------------------------
/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/pkgdown.yml:
--------------------------------------------------------------------------------
1 | pandoc: 3.1.11
2 | pkgdown: 2.0.7
3 | pkgdown_sha: ~
4 | articles:
5 | eph: eph.html
6 | estimacion_pobreza: estimacion_pobreza.html
7 | last_built: 2024-08-06T16:58Z
8 | urls:
9 | reference: https://rindec.github.io/eph/reference
10 | article: https://rindec.github.io/eph/articles
11 |
12 |
--------------------------------------------------------------------------------
/docs/reference/Rplot001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/reference/Rplot001.png
--------------------------------------------------------------------------------
/docs/reference/eph.html:
--------------------------------------------------------------------------------
1 |
2 | eph package — eph • eph
12 |
13 |
14 |
15 |
63 |
64 |
69 |
70 |
71 |
Caja de Herramientas para el procesamiento de la Encuesta Permanente de Hogares
72 |
73 |
74 |
75 |
76 |
Details
77 |
See the README on
78 | Github
79 |
80 |
81 |
82 |
85 |
86 |
87 |
88 |
89 |
Developed by Diego Kozlowski, Pablo Tiscornia, Guido Weksler, Natsumi Shokida, German Rosati, Carolina Pradier.
90 |
91 |
92 |
93 |
Site built with pkgdown 2.0.7.
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/docs/reference/figures/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/reference/figures/logo.png
--------------------------------------------------------------------------------
/docs/reference/is_in_github.html:
--------------------------------------------------------------------------------
1 |
2 | Check if file is in github repo — is_in_github • eph
12 |
13 |
14 |
15 |
63 |
64 |
69 |
70 |
71 |
Check if file is in github repo
72 |
73 |
74 |
75 |
is_in_github ( year = 2018 , trimester = NA , type = "individual" )
76 |
77 |
78 |
79 |
Arguments
80 |
year
81 | el parametro de get_microdata_internal
82 |
83 |
84 | trimester
85 | el parametro de get_microdata_internal
86 |
87 |
88 | type
89 | el parametro de get_microdata_internal
90 |
91 |
92 |
93 |
94 |
97 |
98 |
99 |
100 |
101 |
Developed by Diego Kozlowski, Pablo Tiscornia, Guido Weksler, Natsumi Shokida, German Rosati, Carolina Pradier.
102 |
103 |
104 |
105 |
Site built with pkgdown 2.0.7.
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/docs/reference/libs/leaflet-1.3.1/images/layers-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/reference/libs/leaflet-1.3.1/images/layers-2x.png
--------------------------------------------------------------------------------
/docs/reference/libs/leaflet-1.3.1/images/layers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/reference/libs/leaflet-1.3.1/images/layers.png
--------------------------------------------------------------------------------
/docs/reference/libs/leaflet-1.3.1/images/marker-icon-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/reference/libs/leaflet-1.3.1/images/marker-icon-2x.png
--------------------------------------------------------------------------------
/docs/reference/libs/leaflet-1.3.1/images/marker-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/reference/libs/leaflet-1.3.1/images/marker-icon.png
--------------------------------------------------------------------------------
/docs/reference/libs/leaflet-1.3.1/images/marker-shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/reference/libs/leaflet-1.3.1/images/marker-shadow.png
--------------------------------------------------------------------------------
/docs/reference/libs/leaflet-providers-plugin-2.0.3/leaflet-providers-plugin.js:
--------------------------------------------------------------------------------
1 | LeafletWidget.methods.addProviderTiles = function(provider, layerId, group, options) {
2 | this.layerManager.addLayer(L.tileLayer.provider(provider, options), "tile", layerId, group);
3 | };
4 |
--------------------------------------------------------------------------------
/docs/reference/libs/leaflet-providers-plugin-2.1.1/leaflet-providers-plugin.js:
--------------------------------------------------------------------------------
1 | LeafletWidget.methods.addProviderTiles = function(provider, layerId, group, options) {
2 | this.layerManager.addLayer(L.tileLayer.provider(provider, options), "tile", layerId, group);
3 | };
4 |
--------------------------------------------------------------------------------
/docs/reference/libs/leaflet-providers-plugin-2.2.0/leaflet-providers-plugin.js:
--------------------------------------------------------------------------------
1 | LeafletWidget.methods.addProviderTiles = function(provider, layerId, group, options) {
2 | this.layerManager.addLayer(L.tileLayer.provider(provider, options), "tile", layerId, group);
3 | };
4 |
--------------------------------------------------------------------------------
/docs/reference/libs/leafletfix-1.0.0/leafletfix.css:
--------------------------------------------------------------------------------
1 | /* Work around CSS properties introduced on img by bootstrap */
2 | img.leaflet-tile {
3 | padding: 0;
4 | margin: 0;
5 | border-radius: 0;
6 | border: none;
7 | }
8 | .leaflet .info {
9 | padding: 6px 8px;
10 | font: 14px/16px Arial, Helvetica, sans-serif;
11 | background: white;
12 | background: rgba(255,255,255,0.8);
13 | box-shadow: 0 0 15px rgba(0,0,0,0.2);
14 | border-radius: 5px;
15 | }
16 | .leaflet .legend {
17 | line-height: 18px;
18 | color: #555;
19 | }
20 | .leaflet .legend svg text {
21 | fill: #555;
22 | }
23 | .leaflet .legend svg line {
24 | stroke: #555;
25 | }
26 | .leaflet .legend i {
27 | width: 18px;
28 | height: 18px;
29 | margin-right: 4px;
30 | opacity: 0.7;
31 | display: inline-block;
32 | vertical-align: top;
33 | /*For IE 7*/
34 | zoom: 1;
35 | *display: inline;
36 | }
37 |
--------------------------------------------------------------------------------
/docs/reference/libs/rstudio_leaflet-1.3.1/images/1px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/docs/reference/libs/rstudio_leaflet-1.3.1/images/1px.png
--------------------------------------------------------------------------------
/docs/reference/libs/rstudio_leaflet-1.3.1/rstudio_leaflet.css:
--------------------------------------------------------------------------------
1 | .leaflet-tooltip.leaflet-tooltip-text-only,
2 | .leaflet-tooltip.leaflet-tooltip-text-only:before,
3 | .leaflet-tooltip.leaflet-tooltip-text-only:after {
4 | background: none;
5 | border: none;
6 | box-shadow: none;
7 | }
8 |
9 | .leaflet-tooltip.leaflet-tooltip-text-only.leaflet-tooltip-left {
10 | margin-left: 5px;
11 | }
12 |
13 | .leaflet-tooltip.leaflet-tooltip-text-only.leaflet-tooltip-right {
14 | margin-left: -5px;
15 | }
16 |
17 | .leaflet-tooltip:after {
18 | border-right: 6px solid transparent;
19 | /* right: -16px; */
20 | }
21 |
22 | .leaflet-popup-pane .leaflet-popup-tip-container {
23 | /* when the tooltip container is clicked, it is closed */
24 | pointer-events: all;
25 | /* tooltips should display the "hand" icon, just like .leaflet-interactive*/
26 | cursor: pointer;
27 | }
28 |
29 | /* have the widget be displayed in the right 'layer' */
30 | .leaflet-map-pane {
31 | z-index: auto;
32 | }
33 |
34 | /* Add missing rule from leaflet for img.
35 | This complete existing leaflet.css.
36 | Fix for https://github.com/rstudio/rmarkdown/issues/1949 */
37 | .leaflet-container .leaflet-right-pane img,
38 | .leaflet-container .leaflet-left-pane img {
39 | max-width: none !important;
40 | max-height: none !important;
41 | }
42 |
--------------------------------------------------------------------------------
/docs/reference/pipe.html:
--------------------------------------------------------------------------------
1 |
2 | Pipe operator — %>% • eph
12 |
13 |
14 |
15 |
63 |
64 |
69 |
70 |
73 |
74 |
77 |
78 |
79 |
80 |
83 |
84 |
85 |
86 |
89 |
90 |
91 |
Sitio creado con pkgdown 2.0.7.
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/docs/sitemap.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | https://rindec.github.io/eph/404.html
5 |
6 |
7 | https://rindec.github.io/eph/LICENSE-text.html
8 |
9 |
10 | https://rindec.github.io/eph/LICENSE.html
11 |
12 |
13 | https://rindec.github.io/eph/articles/eph.html
14 |
15 |
16 | https://rindec.github.io/eph/articles/estimacion_pobreza.html
17 |
18 |
19 | https://rindec.github.io/eph/articles/index.html
20 |
21 |
22 | https://rindec.github.io/eph/authors.html
23 |
24 |
25 | https://rindec.github.io/eph/index.html
26 |
27 |
28 | https://rindec.github.io/eph/news/index.html
29 |
30 |
31 | https://rindec.github.io/eph/reference/CNO.html
32 |
33 |
34 | https://rindec.github.io/eph/reference/adulto_equivalente.html
35 |
36 |
37 | https://rindec.github.io/eph/reference/caes.html
38 |
39 |
40 | https://rindec.github.io/eph/reference/calculate_errors.html
41 |
42 |
43 | https://rindec.github.io/eph/reference/calculate_poverty.html
44 |
45 |
46 | https://rindec.github.io/eph/reference/calculate_tabulates.html
47 |
48 |
49 | https://rindec.github.io/eph/reference/canastas_reg_example.html
50 |
51 |
52 | https://rindec.github.io/eph/reference/centroides_aglomerados.html
53 |
54 |
55 | https://rindec.github.io/eph/reference/diccionario_aglomerados.html
56 |
57 |
58 | https://rindec.github.io/eph/reference/diccionario_regiones.html
59 |
60 |
61 | https://rindec.github.io/eph/reference/eph.html
62 |
63 |
64 | https://rindec.github.io/eph/reference/errores_muestrales.html
65 |
66 |
67 | https://rindec.github.io/eph/reference/get_eahu.html
68 |
69 |
70 | https://rindec.github.io/eph/reference/get_microdata.html
71 |
72 |
73 | https://rindec.github.io/eph/reference/get_microdata_internal.html
74 |
75 |
76 | https://rindec.github.io/eph/reference/get_poverty_lines.html
77 |
78 |
79 | https://rindec.github.io/eph/reference/get_total_urbano.html
80 |
81 |
82 | https://rindec.github.io/eph/reference/index.html
83 |
84 |
85 | https://rindec.github.io/eph/reference/is_in_github.html
86 |
87 |
88 | https://rindec.github.io/eph/reference/map_agglomerates.html
89 |
90 |
91 | https://rindec.github.io/eph/reference/map_aglomerados.html
92 |
93 |
94 | https://rindec.github.io/eph/reference/organize_caes.html
95 |
96 |
97 | https://rindec.github.io/eph/reference/organize_cno.html
98 |
99 |
100 | https://rindec.github.io/eph/reference/organize_labels.html
101 |
102 |
103 | https://rindec.github.io/eph/reference/organize_ocupations.html
104 |
105 |
106 | https://rindec.github.io/eph/reference/organize_panels.html
107 |
108 |
109 | https://rindec.github.io/eph/reference/pipe.html
110 |
111 |
112 | https://rindec.github.io/eph/reference/toybase_hogar_2016_04.html
113 |
114 |
115 | https://rindec.github.io/eph/reference/toybase_individual_2016_03.html
116 |
117 |
118 | https://rindec.github.io/eph/reference/toybase_individual_2016_04.html
119 |
120 |
121 |
--------------------------------------------------------------------------------
/eph.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 |
3 | RestoreWorkspace: No
4 | SaveWorkspace: No
5 | AlwaysSaveHistory: No
6 |
7 | EnableCodeIndexing: Yes
8 | UseSpacesForTab: Yes
9 | NumSpacesForTab: 2
10 | Encoding: UTF-8
11 |
12 | RnwWeave: Sweave
13 | LaTeX: pdfLaTeX
14 |
15 | AutoAppendNewline: Yes
16 | StripTrailingWhitespace: Yes
17 |
18 | BuildType: Package
19 | PackageUseDevtools: Yes
20 | PackageInstallArgs: --no-multiarch --with-keep.source
21 | PackageRoxygenize: rd,collate,namespace
22 |
--------------------------------------------------------------------------------
/inst/CITATION:
--------------------------------------------------------------------------------
1 | citHeader("Para citar el paquete eph puedes usar:")
2 |
3 | bibentry(
4 | bibtype = "Manual",
5 | key = 'kozlowski2020',
6 | title = "eph: Argentina's Permanent Household Survey Data and Manipulation Utilities",
7 | author = "Diego Kozlowski, Pablo Tiscornia, Guido Weksler, German Rosati and Natsumi Shokida",
8 | year = 2020,
9 | DOI = "10.5281/zenodo.3462677",
10 |
11 | url = "https://github.com/ropensci/eph",
12 | textVersion = paste(
13 | "Diego Kozlowski, Pablo Tiscornia, Guido Weksler, German Rosati and Natsumi Shokida (2020).
14 | eph: Argentina's Permanent Household Survey Data and Manipulation Utilities. R package
15 | version https://doi.org/10.5281/zenodo.3462677"
16 |
17 | )
18 | )
19 |
--------------------------------------------------------------------------------
/man/CNO.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/CNO.R
3 | \docType{data}
4 | \name{CNO}
5 | \alias{CNO}
6 | \title{Categorias de las 4 dimensiones del Clasificador Nacional de Ocupaciones 2001.}
7 | \format{
8 | Un data frame con 63 filas y 4 variables
9 |
10 | \describe{
11 | \item{digit}{digito para identificar la dimension del CNO}
12 | \item{value}{valor que toma cada categoria dentro de una dimension}
13 | \item{label}{nombre de la categoria propia a una dimension}
14 | \item{variable}{nombre de la dimension del CNO}
15 |
16 | }
17 | }
18 | \usage{
19 | CNO
20 | }
21 | \description{
22 | Categorias de las 4 dimensiones del Clasificador Nacional de Ocupaciones 2001.
23 | }
24 | \keyword{datasets}
25 |
--------------------------------------------------------------------------------
/man/adulto_equivalente.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/adulto_equivalente.R
3 | \docType{data}
4 | \name{adulto_equivalente}
5 | \alias{adulto_equivalente}
6 | \title{Tabla de valores de adulto equivalente segun sexo y edad}
7 | \format{
8 | Un data frame con 222 filas y 3 variables
9 |
10 | \describe{
11 | \item{CH04}{sexo}
12 | \item{CH06}{edad}
13 | \item{adequi}{unidades de adulto equivalente}
14 |
15 | }
16 | }
17 | \usage{
18 | adulto_equivalente
19 | }
20 | \description{
21 | Tabla de valores de adulto equivalente segun sexo y edad
22 | }
23 | \details{
24 | De acuerdo con la metodologia de [INDEC](https://www.indec.gob.ar/ftp/cuadros/sociedad/preguntas_frecuentes_cba_cbt.pdf):
25 |
26 | "Para identificar la unidad consumidora de referencia, o adulto equivalente, se analizo en que grupo de edad se ubicaba la mayor concentracion de poblacion activa, y fue la categoria de hombres de 30 a 60 anios de edad la que presentaba el mayor peso relativo dentro del conjunto total de la poblacion de referencia. Por este motivo se considero como adulto equivalente al hombre de 30 a 60 anios con un estilo de vida moderadamente activo y no otro grupo poblacional."
27 | }
28 | \keyword{datasets}
29 |
--------------------------------------------------------------------------------
/man/caes.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/caes.R
3 | \docType{data}
4 | \name{caes}
5 | \alias{caes}
6 | \title{Categorias del Clasificador de Actividades Economicas para encuestas Sociodemograficas}
7 | \format{
8 | Un data frame con 140 filas y 8 variables:
9 | \describe{
10 | \item{caes_version}{(character) Version del CAES utilizada}
11 | \item{PP04B_COD}{(character) Codigo clase CAES. 4 digitos (nivel 3) Variable que aparece en microdatos EPH}
12 | \item{PP04B_label}{(character) Etiqueta clase CAES}
13 | \item{caes_seccion_cod}{(character) Codigo seccion CAES. 2 digitos (nivel 2)}
14 | \item{caes_seccion_label}{(character) Etiqueta seccion CAES}
15 | \item{caes_division_cod}{(character) Codigo division CAES. Letra (nivel 1)}
16 | \item{caes_division_label}{(character) Etiqueta division CAES}
17 | \item{caes_eph_cod}{(character) Codigo reagrupamiento de CAES utilizado por EPH (nivel 1)}
18 | \item{caes_eph_label}{(factor) Etiqueta reagrupamiento de CAES utilizado por EPH (nivel 1)}
19 | }
20 | }
21 | \usage{
22 | caes
23 | }
24 | \description{
25 | Base con codigos y etiquetas del Clasificador de actividades economicas para encuestas sociodemograficas.
26 | CAES Mercosur 1.0 - Actualizacion 2018.
27 | Basado en https://bit.ly/notas-explicativas-CAES-v2018 y
28 | https://www.indec.gob.ar/ftp/cuadros/menusuperior/clasificadores/caes_v2018.xls,
29 | obtenidos de
30 | https://www.indec.gob.ar/indec/web/Institucional-Indec-Clasificadores
31 | }
32 | \keyword{datasets}
33 |
--------------------------------------------------------------------------------
/man/calculate_errors.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/calculate_errors.R
3 | \name{calculate_errors}
4 | \alias{calculate_errors}
5 | \title{Calculo del desvio estandar y el coeficiente de variacion}
6 | \usage{
7 | calculate_errors(
8 | value,
9 | codigo_aglo = "Total",
10 | periodo_eph = "2014.03",
11 | measure = "cv"
12 | )
13 | }
14 | \arguments{
15 | \item{value}{Vector numerico de las estimaciones de poblacion para las
16 | que se desea hallar el desvio estandar o el coeficiente de variacion.}
17 |
18 | \item{codigo_aglo}{default = "Total". String con el codigo numerico del aglomerado al que
19 | pertenecen las estimaciones. "Total" para trabajar estimaciones del conjunto de 31 aglomerados urbanos.}
20 |
21 | \item{periodo_eph}{default = "2014.03". String indicando el periodo al que corresponde la EPH. "2014.03" para
22 | obtener los errores muestrales correspondientes al tercer trimestre de 2014 en adelante. "2003.03_2014.02"
23 | para los errores muestrales del tercer trimestre del 2003 al segundo trimestre del 2014.}
24 |
25 | \item{measure}{default = "cv". String indicando la medida que se desea obtener. "cv" para obtener el coeficiente de variacion
26 | correspondiente a las estimaciones o "ds" para obtener el desvio estandar.}
27 | }
28 | \value{
29 | Devuelve la estimacion de un total poblacional agregando el desvio estandar o el coeficiente de variacion correspondiente segun las tablas de error muestral de INDEC para EPH continua a partir del segundo trimestre 2003
30 | }
31 | \description{
32 | Asigna a una estimacion de un total poblacional el desvio estandar o el coeficiente de variacion
33 | correspondiente segun las tablas de error muestral de INDEC para EPH continua
34 | a partir del segundo trimestre 2003.
35 | (Ver `errores_muestrales`)
36 | }
37 | \details{
38 | disclaimer: El script no es un producto oficial de INDEC.
39 | }
40 | \examples{
41 |
42 | tabla <- eph::toybase_individual_2016_03 \%>\%
43 | eph::organize_labels() \%>\%
44 | dplyr::filter(AGLOMERADO == 32) \%>\%
45 | eph::calculate_tabulates(
46 | x = "CH03",
47 | weights = "PONDERA",
48 | add.totals = "row"
49 | )
50 | tabla \%>\%
51 | dplyr::mutate(ds = calculate_errors(Freq,
52 | codigo_aglo = "32",
53 | periodo_eph = "2014.03", measure = "ds"
54 | ))
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/man/calculate_poverty.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/calculate_poverty.R
3 | \name{calculate_poverty}
4 | \alias{calculate_poverty}
5 | \title{Calculo de Pobreza e Indigencia}
6 | \usage{
7 | calculate_poverty(
8 | base,
9 | basket,
10 | print_summary = TRUE,
11 | window = "quarter",
12 | group_vars = c()
13 | )
14 | }
15 | \arguments{
16 | \item{base}{Base individual de uno o mas periodos}
17 |
18 | \item{basket}{canasta basica alimentaria y total, con la estructura de la canasta de ejemplo (ver `canastas_reg_example`)}
19 |
20 | \item{print_summary}{default = TRUE. Opcion para imprimir las tasas de pobreza e indigencia (proporcion de individuos)}
21 |
22 | \item{window}{default = "quarter". Opcion para cambiar el lapso del calculo que se imprime en consola.
23 | "quarter" (para estimacion trimestral) o "semester" (estimacion semestral)}
24 |
25 | \item{group_vars}{Opcion para agregar variables agrupadoras para el calculo que se imprime en consola.}
26 | }
27 | \value{
28 | Devuelve la base agregando informacion respecto a la situacion de cada hogar en terminos de sus ingresos: indigente, pobre o no pobre (a estos fines, se agregan 5 columnas nuevas).
29 | }
30 | \description{
31 | Funcion para calcular la pobreza e indigencia siguiendo la metodologia de linea.
32 | }
33 | \details{
34 | disclaimer: El script no es un producto oficial de INDEC.
35 | }
36 | \examples{
37 |
38 | bases <- dplyr::bind_rows(
39 | toybase_individual_2016_03,
40 | toybase_individual_2016_04
41 | )
42 |
43 | base_pobreza <- calculate_poverty(
44 | base = bases,
45 | basket = canastas_reg_example,
46 | print_summary = TRUE,
47 | group_vars = c(CH04, NIVEL_ED),
48 | window = "semestral"
49 | )
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/man/calculate_tabulates.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/calculate_tabulates.R
3 | \name{calculate_tabulates}
4 | \alias{calculate_tabulates}
5 | \title{Tabulado con ponderacion}
6 | \usage{
7 | calculate_tabulates(
8 | base,
9 | x,
10 | y = NULL,
11 | weights = NULL,
12 | affix_sign = FALSE,
13 | digits = 1,
14 | add.totals = "none",
15 | add.percentage = "none"
16 | )
17 | }
18 | \arguments{
19 | \item{base}{Dataframe}
20 |
21 | \item{x}{string con el nombre de la variable a tabular}
22 |
23 | \item{y}{otro string (opcional) con el nombre de una segunda variable, para una tabla de doble entrada. Tiene que ser de igual largo que x}
24 |
25 | \item{weights}{string con el nombre de la variable con los pesos de pesos, tiene que ser de igual largo que x}
26 |
27 | \item{affix_sign}{si es TRUE agrega el signo \% al final}
28 |
29 | \item{digits}{numero de digitos significativos}
30 |
31 | \item{add.totals}{toma los valores c('none','row','col','both'), para agregar totales por fila, columna o ambos}
32 |
33 | \item{add.percentage}{toma los valores c('none','row','col'), para agregar porcentajes por fila y columna}
34 | }
35 | \value{
36 | Devuelve un tabulado uni o bivariado con ponderacion, totales parciales y porcentajes.
37 | }
38 | \description{
39 | Funcion para crear tabulados uni o bivariados con ponderacion, totales parciales y porcentajes.
40 | }
41 | \examples{
42 |
43 |
44 | ### Tabla simple ###
45 |
46 | calculate_tabulates(
47 | base = toybase_individual_2016_04,
48 | x = "REGION", y = "CH04",
49 | weights = "PONDERA"
50 | )
51 |
52 | ### Totales por fila ###
53 |
54 | calculate_tabulates(
55 | base = toybase_individual_2016_04,
56 | x = "REGION", y = "CH04",
57 | weights = "PONDERA", add.totals = "row"
58 | )
59 |
60 | ### Totales por columna ###
61 |
62 | calculate_tabulates(
63 | base = toybase_individual_2016_04,
64 | x = "REGION", y = "CH04",
65 | weights = "PONDERA", add.totals = "col"
66 | )
67 |
68 | ### Porcentajes por fila ###
69 |
70 | calculate_tabulates(
71 | base = toybase_individual_2016_04,
72 | x = "REGION", y = "CH04",
73 | weights = "PONDERA", add.percentage = "row"
74 | )
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/man/canastas_reg_example.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/canastas_reg_example.R
3 | \docType{data}
4 | \name{canastas_reg_example}
5 | \alias{canastas_reg_example}
6 | \title{Canastas Basicas Alimentarias y Canastas Basicas Totales segun region y trimestre}
7 | \format{
8 | Un data frame con 12 filas y 5 variables
9 |
10 | \describe{
11 | \item{region}{Nombre de region}
12 | \item{periodo}{Anio.trimestre}
13 | \item{CBA}{canasta basica alimentaria}
14 | \item{CBT}{inversa del coeficiente de engels}
15 | \item{codigo}{codigo de region}
16 | ...
17 | }
18 | }
19 | \usage{
20 | canastas_reg_example
21 | }
22 | \description{
23 | Esta base tiene el formato necesario para el calculo de pobreza
24 | }
25 | \keyword{datasets}
26 |
--------------------------------------------------------------------------------
/man/centroides_aglomerados.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/centroides_aglomerados.R
3 | \docType{data}
4 | \name{centroides_aglomerados}
5 | \alias{centroides_aglomerados}
6 | \title{Tabla de centroides de los aglomerados}
7 | \format{
8 | Un data frame con 32 filas y 4 variables:
9 | \describe{
10 | \item{AGLOMERADO}{(Factor) Codigo de aglomerado EPH}
11 | \item{nombre_aglomerado}{(Factor) Nombre del aglomerado EPH}
12 | \item{lat}{Latitud del aglomerado EPH}
13 | \item{lon}{Longitud del aglomerado EPH}
14 | }
15 | }
16 | \usage{
17 | centroides_aglomerados
18 | }
19 | \description{
20 | Base con centroides de los aglomerados de EPH.
21 | Basado en https://www.indec.gob.ar/indec/web/Nivel4-Tema-1-39-120
22 | }
23 | \keyword{datasets}
24 |
--------------------------------------------------------------------------------
/man/diccionario_aglomerados.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/diccionario_aglomerados.R
3 | \docType{data}
4 | \name{diccionario_aglomerados}
5 | \alias{diccionario_aglomerados}
6 | \title{Diccionario de aglomerados segun diseno de registro de la EPH}
7 | \format{
8 | Un data frame con 32 filas y 2 variables
9 |
10 | \describe{
11 | \item{codigo}{Codigo de aglomerado}
12 | \item{aglo}{Nombre del aglomerado}
13 |
14 | }
15 | }
16 | \usage{
17 | diccionario_aglomerados
18 | }
19 | \description{
20 | Diccionario de aglomerados segun diseno de registro de la EPH
21 | }
22 | \keyword{datasets}
23 |
--------------------------------------------------------------------------------
/man/diccionario_regiones.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/diccionario_regiones.R
3 | \docType{data}
4 | \name{diccionario_regiones}
5 | \alias{diccionario_regiones}
6 | \title{Diccionario de regiones segun diseno de registro de la EPH}
7 | \format{
8 | Un data frame con 6 filas y 2 variables
9 |
10 | \describe{
11 | \item{codigo}{Codigo de region}
12 | \item{region}{Nombre de region}
13 |
14 | }
15 | }
16 | \usage{
17 | diccionario_regiones
18 | }
19 | \description{
20 | Diccionario de regiones segun diseno de registro de la EPH
21 | }
22 | \keyword{datasets}
23 |
--------------------------------------------------------------------------------
/man/errores_muestrales.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/errores_muestrales.R
3 | \docType{data}
4 | \name{errores_muestrales}
5 | \alias{errores_muestrales}
6 | \title{Tabla con los errores muestrales para estimaciones de poblacion}
7 | \format{
8 | Un data frame con 1687 filas y 5 variables:
9 | \describe{
10 | \item{\code{codigo}}{character ---String con codigo numerico de los 31 aglomerados, "Gran Buenos Aires"
11 | (solo para 2003.03 a 2014.02), o con "Total" para el conjunto de los 31 aglomerados---}
12 | \item{\code{aglomerado}}{character ---String con el nombre del aglomerado---}
13 | \item{\code{periodo}}{character ---String indicando el periodo de EPH que corresponde, "2014.03"
14 | para datos de EPH a partir del tercer trimestre 2014, o "2003.03_2014.02" para datos anteriores---}
15 | \item{\code{x}}{double ---Estimacion de poblacion para la cual se desea conocer el error muestral---}
16 | \item{\code{ds}}{double ---Desvio Estandar correspondiente a la estimacion de poblacion en el aglomerado---}
17 | \item{\code{cv}}{double ---Coeficiente de Variacion correspondiente a la estimacion de poblacion en el aglomerado---}
18 | }
19 | }
20 | \usage{
21 | errores_muestrales
22 | }
23 | \description{
24 | Base con los errores muestrales para estimaciones de poblacion en los aglomerados urbanos
25 | para la EPH continua desde 2003 segundo trimestre segun documentacion de INDEC:
26 | https://www.indec.gob.ar/ftp/cuadros/menusuperior/eph/EPH_errores_muestreo_3t2014.pdf
27 | https://www.indec.gob.ar/ftp/cuadros/menusuperior/eph/EPH_errores_muestreo.pdf
28 | }
29 | \keyword{datasets}
30 |
--------------------------------------------------------------------------------
/man/figures/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/man/figures/logo.png
--------------------------------------------------------------------------------
/man/get_eahu.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_eahu.R
3 | \name{get_eahu}
4 | \alias{get_eahu}
5 | \title{Descarga de Bases de la Encuesta anual de hogares urbanos}
6 | \usage{
7 | get_eahu(year = 2010, type = "individual", vars = "all", destfile = NULL)
8 | }
9 | \arguments{
10 | \item{year}{un integer o vector de integers entre 2010 y 2014}
11 |
12 | \item{type}{tipo de base a descargar: 'individual' ; 'hogar'}
13 |
14 | \item{vars}{opcional: un vector de characters. variables a seleccionar. Default = 'all' trae todas las variables}
15 |
16 | \item{destfile}{opcional: un string con la direccion de un archivo .RDS. Si se ingresa un path a un archivo que no existe, se descarga
17 | el archivo y se graba en esa direccion. Si existe un archivo en ese path, se lee el archivo.}
18 | }
19 | \value{
20 | Devuelve la o las bases de la EAHU solicitadas
21 | }
22 | \description{
23 | Funcion que descarga bases de la Encuesta anual de hogares urbanos del INDEC entre 2010 y 2014
24 | }
25 | \details{
26 | disclaimer: El script no es un producto oficial de INDEC.
27 | }
28 | \examples{
29 | \dontrun{
30 | base_individual <- get_eahu(
31 | year = 2010,
32 | type = "individual",
33 | vars = c("SUBDOMINIO", "PONDERA", "ESTADO", "CAT_OCUP")
34 | )
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/man/get_microdata.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_microdata.R
3 | \name{get_microdata}
4 | \alias{get_microdata}
5 | \title{Descarga de Bases de EPH}
6 | \usage{
7 | get_microdata(
8 | year = 2018,
9 | period = 1,
10 | type = "individual",
11 | vars = "all",
12 | destfile = NULL,
13 | ...
14 | )
15 | }
16 | \arguments{
17 | \item{year}{un integer o vector de integers a partir de 2003}
18 |
19 | \item{period}{un integer o vector de integers con el numero de trimestre u onda: 1,2,3,4, para la EPH continua, y 1 o 2, para la EPH puntual}
20 |
21 | \item{type}{un character o vector de characters con el tipo de base a descargar: 'individual'; 'hogar', default individual}
22 |
23 | \item{vars}{opcional: un vector de characters. variables a seleccionar. Default='all' trae todas las variables}
24 |
25 | \item{destfile}{opcional: un string con la direccion de un archivo .RDS. Si se ingresa un path a un archivo que no existe, se descarga
26 | el archivo y se graba en esa direccion. Si existe un archivo en ese path, se lee el archivo.}
27 |
28 | \item{...}{asegura el funcionamiento de la funcion en su version anterior con los parametros wave o trimester}
29 | }
30 | \value{
31 | Devuelve la o las bases de la EPH solicitadas
32 | }
33 | \description{
34 | Funcion que descarga bases de la Encuesta Permanente de Hogares del INDEC a partir de 1996
35 | }
36 | \details{
37 | Las bases de la EPH puntual utilizan el parametro period para referirse a las ondas.
38 | Su alcance es entre la onda 1 de 1996 y la onda 1 de 2003.
39 |
40 | Las bases de la EPH continua utilizan el parametro period para referirse a los trimestres.
41 | Su alcance es entre tercer trimestre de 2003 a la actualidad
42 | disclaimer: El script no es un producto oficial de INDEC.
43 | }
44 | \examples{
45 |
46 | base_individual <- get_microdata(
47 | year = 2018:2019,
48 | period = 1,
49 | type = "individual",
50 | vars = c("PONDERA", "ESTADO", "CAT_OCUP")
51 | )
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/man/get_poverty_lines.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_poverty_lines.R
3 | \name{get_poverty_lines}
4 | \alias{get_poverty_lines}
5 | \title{Descarga de canasta basica alimentaria y canasta basica total}
6 | \usage{
7 | get_poverty_lines(regional = FALSE)
8 | }
9 | \arguments{
10 | \item{regional}{booleano, default = FALSE. Si es TRUE, descarga los datos de canastas regionales
11 | que se utilizan para el calculo de pobreza. Si es FALSE, descarga la serie de GBA
12 | provista por indec en https://www.indec.gob.ar/indec/web/Nivel4-Tema-4-43-149}
13 | }
14 | \value{
15 | Devuelve una tabla con la CBA y CBT a partir de abril 2016
16 | }
17 | \description{
18 | Funcion que descarga la CBA y CBT a partir de abril 2016
19 | }
20 | \details{
21 | disclaimer: El script no es un producto oficial de INDEC.
22 | }
23 | \examples{
24 |
25 | canasta <- get_poverty_lines(regional = TRUE)
26 | canasta
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/man/get_total_urbano.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_total_urbano.R
3 | \name{get_total_urbano}
4 | \alias{get_total_urbano}
5 | \title{Descarga de Bases de EPH total urbano}
6 | \usage{
7 | get_total_urbano(
8 | year = 2016,
9 | type = "individual",
10 | vars = "all",
11 | destfile = NULL
12 | )
13 | }
14 | \arguments{
15 | \item{year}{un integer o vector de integers a partir de 2016}
16 |
17 | \item{type}{tipo de base a descargar: 'individual' ; 'hogar'}
18 |
19 | \item{vars}{opcional: un vector de characters. variables a seleccionar. Default = 'all' trae todas las variables}
20 |
21 | \item{destfile}{opcional: un string con la direccion de un archivo .RDS. Si se ingresa un path a un archivo que no existe, se descarga
22 | el archivo y se graba en esa direccion. Si existe un archivo en ese path, se lee el archivo.}
23 | }
24 | \value{
25 | Devuelve la o las bases de la EPH total urbano solicitadas
26 | }
27 | \description{
28 | Funcion que descarga bases de la Encuesta Permanente de Hogares total urbano del INDEC a partir de 2016
29 | }
30 | \details{
31 | disclaimer: El script no es un producto oficial de INDEC.
32 | }
33 | \examples{
34 | \dontrun{
35 | base_individual <- get_total_urbano(
36 | year = 2016,
37 | type = "hogar",
38 | vars = c("PONDERA", "IV1", "IV2")
39 | )
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/man/map_agglomerates.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/map_agglomerates.R
3 | \name{map_agglomerates}
4 | \alias{map_agglomerates}
5 | \title{Mapa de indicadores por aglomerado}
6 | \usage{
7 | map_agglomerates(
8 | .data,
9 | agglomerates,
10 | indicator,
11 | alpha = 0.75,
12 | palette = "viridis"
13 | )
14 | }
15 | \arguments{
16 | \item{.data}{Dataframe con los datos}
17 |
18 | \item{agglomerates}{Variable con los codigos de aglomerados}
19 |
20 | \item{indicator}{Variable con los indicadores}
21 |
22 | \item{alpha}{Opacidad de los puntos}
23 |
24 | \item{palette}{Paleta de colores a utilizar, incluye "viridis", "magma", "inferno", or "plasma". Para mas opciones, ver \link[leaflet]{colorNumeric}}
25 | }
26 | \value{
27 | Devuelve un mapa de indicadores por aglomerado
28 | }
29 | \description{
30 | Mapa de indicadores por aglomerado
31 | }
32 | \examples{
33 |
34 | toybase_individual_2016_04 \%>\%
35 | dplyr::group_by(AGLOMERADO) \%>\%
36 | dplyr::summarise(tasa_actividad = sum(PONDERA[ESTADO == 1]) / sum(PONDERA)) \%>\%
37 | map_agglomerates(
38 | agglomerates = AGLOMERADO,
39 | indicator = tasa_actividad
40 | )
41 | }
42 |
--------------------------------------------------------------------------------
/man/organize_caes.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/organize_caes.R
3 | \name{organize_caes}
4 | \alias{organize_caes}
5 | \title{Clasificador de Actividades}
6 | \usage{
7 | organize_caes(base)
8 | }
9 | \arguments{
10 | \item{base}{Base individual de uno o mas periodos}
11 | }
12 | \value{
13 | Devuelve la base con 8 columnas nuevas (ver `caes`)
14 | }
15 | \description{
16 | Funcion para clasificar las actividades economicas segun el
17 | Clasificador de actividades economicas para encuestas sociodemograficas.
18 | CAES Mercosur 1.0 y CAES Mercosur.
19 | Basado en https://www.indec.gob.ar/ftp/cuadros/menusuperior/clasificadores/notas_explicativas_caes_v2018.pdf
20 | }
21 | \details{
22 | disclaimer: El script no es un producto oficial de INDEC.
23 |
24 | No olvides contemplar los cambios en la codificacion y categorias de las distintas versiones del clasificador CAES para la elaboracion de series de largo plazo.
25 | }
26 | \examples{
27 | bases <- dplyr::bind_rows(toybase_individual_2016_03, toybase_individual_2016_04)
28 | bases_clasificadas <- organize_caes(base = bases)
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/man/organize_cno.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/organize_cno.R
3 | \name{organize_cno}
4 | \alias{organize_cno}
5 | \title{Clasificador de Ocupaciones}
6 | \usage{
7 | organize_cno(base)
8 | }
9 | \arguments{
10 | \item{base}{Base individual de uno o mas periodos}
11 | }
12 | \value{
13 | Devuelve la base con 4 columnas nuevas (que indican la informacion correspondiente al Clasificador Nacional de Ocupaciones)
14 | }
15 | \description{
16 | Funcion para clasificar las ocupaciones segun las 4 dimensiones del Clasificador Nacional de Ocupaciones
17 | (CNO 2001)
18 | }
19 | \details{
20 | Importante: Verificar que el clasificador CNO 2001 sea compatible con la base que estes utilizando.
21 |
22 | disclaimer: El script no es un producto oficial de INDEC.
23 | }
24 | \examples{
25 |
26 |
27 | bases <- dplyr::bind_rows(toybase_individual_2016_03, toybase_individual_2016_04)
28 | bases_clasificadas <- organize_cno(base = bases)
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/man/organize_labels.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/organize_labels.R
3 | \name{organize_labels}
4 | \alias{organize_labels}
5 | \title{Funcion para etiquetar las bases de la Encuesta Permanente de Hogares.}
6 | \usage{
7 | organize_labels(df, type = "individual")
8 | }
9 | \arguments{
10 | \item{df}{type de microdatos de la EPH}
11 |
12 | \item{type}{(string) aclaracion sobre si la base a etiquetar es de tipo 'individual' u 'hogar'}
13 | }
14 | \value{
15 | Devuelve la base con sus variables etiquetadas de acuerdo con el disenio de registro de la EPH (no renombra los valores o nombres de las columnas, agrega etiquetas con esta información)
16 | }
17 | \description{
18 | Funcion para etiquetar las bases de la Encuesta Permanente de Hogares.
19 | }
20 | \details{
21 | disclaimer: El script no es un producto oficial de INDEC.
22 | }
23 | \examples{
24 | df <- organize_labels(toybase_individual_2016_04, type = "individual")
25 | }
26 |
--------------------------------------------------------------------------------
/man/organize_panels.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/organize_panels.R
3 | \name{organize_panels}
4 | \alias{organize_panels}
5 | \title{Pool de Datos en Panel - Base Individudal EPH continua}
6 | \usage{
7 | organize_panels(bases, variables, window = "anual")
8 | }
9 | \arguments{
10 | \item{bases}{Lista de bases de microdatos a utilizar para armar el pool de datos}
11 |
12 | \item{variables}{Vector con nombres de las variables de interes}
13 |
14 | \item{window}{Especificar distancia temporal entre las observaciones. anual o trimestral}
15 | }
16 | \value{
17 | Devuelve el pool de datos de panel
18 | }
19 | \description{
20 | Permite armar un pool de datos en panel de la EPH continua a partir
21 | de especificar una serie consecutiva de bases, variables y el largo de la ventana -window- de observacion
22 | }
23 | \details{
24 | disclaimer: El script no es un producto oficial de INDEC.
25 | }
26 | \examples{
27 |
28 | lista_bases <- list(toybase_individual_2016_03, toybase_individual_2016_04)
29 | pool_trimestral <- organize_panels(
30 | bases = lista_bases,
31 | variables = c("P21", "ESTADO"),
32 | window = "trimestral"
33 | )
34 | }
35 |
--------------------------------------------------------------------------------
/man/pipe.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils-pipe.R
3 | \name{\%>\%}
4 | \alias{\%>\%}
5 | \title{Pipe operator}
6 | \usage{
7 | lhs \%>\% rhs
8 | }
9 | \description{
10 | Pipe operator
11 | }
12 | \keyword{internal}
13 |
--------------------------------------------------------------------------------
/pkgdown/_pkgdown.yml:
--------------------------------------------------------------------------------
1 | url: https://rindec.github.io/eph/
2 |
3 | lang: es
4 |
5 | home:
6 | title: Paquete de herramientas para la Encuesta Permanente de Hogares
7 |
8 | authors:
9 | Diego Kozlowski:
10 | href: "https://github.com/DiegoKoz"
11 | Pablo Tiscornia:
12 | href: "https://github.com/pablotis"
13 | Guido Weksler:
14 | href: "https://github.com/Guidowe"
15 | Natsumi Shokida:
16 | href: "https://github.com/natsushok"
17 | German Rosati:
18 | href: "https://github.com/gefero"
19 | Carolina Pradier:
20 | href: "https://github.com/caropradier"
21 | Juan Gabriel Juara:
22 | href: "https://github.com/jgjuara"
23 |
24 | destination: docs
25 |
26 | toc:
27 | depth: 2
28 | template:
29 | params:
30 | bootswatch: united
31 | ganalytics: UA-122515754-3
32 | navbar:
33 | type: inverse
34 |
35 |
36 | reference:
37 | - title: Descarga y recodificación
38 | desc: Funciones para descargar los datos de la encuesta y recodificar sus variables.
39 | contents:
40 | - get_microdata
41 | - starts_with("organize")
42 | - get_total_urbano
43 | - get_eahu
44 | - title: Tablas auxiliares
45 | desc: Tablas auxiliares para la recodificacion y otros calculos frecuentes.
46 | contents:
47 | - get_poverty_lines
48 | - adulto_equivalente
49 | - starts_with("diccionario")
50 | - errores_muestrales
51 | - CNO
52 | - caes
53 | - centroides_aglomerados
54 | - title: Procesamiento
55 | desc: Funciones para facilitar procesamientos básicos de la base de datos (incluyendo mapeo)
56 | contents:
57 | - starts_with("calculate")
58 | - starts_with("map")
59 | - title: Ejemplos y bases de juguete
60 | contents:
61 | - starts_with("toy")
62 | - canastas_reg_example
63 |
64 |
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/pkgdown/favicon/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/pkgdown/favicon/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/pkgdown/favicon/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/pkgdown/favicon/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/pkgdown/favicon/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/pkgdown/favicon/apple-touch-icon.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/pkgdown/favicon/favicon-16x16.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/pkgdown/favicon/favicon-32x32.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ropensci/eph/60ea2982cc8fe7f51340f0d65a04450576aa24a4/pkgdown/favicon/favicon.ico
--------------------------------------------------------------------------------
/tests/testthat.R:
--------------------------------------------------------------------------------
1 | library(testthat)
2 | library(httptest)
3 | library(eph)
4 |
5 | test_check("eph")
6 |
--------------------------------------------------------------------------------
/tests/testthat/test-calculate_errors.R:
--------------------------------------------------------------------------------
1 | test_that("checkear shape ds", {
2 | tabla <- eph::toybase_individual_2016_03 %>%
3 | eph::organize_labels() %>%
4 | dplyr::filter(AGLOMERADO == 32) %>%
5 | calculate_tabulates(
6 | x = "CH03",
7 | weights = "PONDERA",
8 | add.totals = "row"
9 | )
10 |
11 | tabla_errors <- tabla %>%
12 | dplyr::mutate(ds = calculate_errors(Freq,
13 | codigo_aglo = "32",
14 | periodo_eph = "2014.03", measure = "ds"
15 | ))
16 |
17 | expect_equal(ncol(tabla_errors), 3)
18 | expect_equal(nrow(tabla_errors), nrow(tabla))
19 | expect_equal(tabla_errors[1, 3], 5869)
20 | })
21 |
22 |
23 | test_that("checkear shape cv", {
24 | tabla <- eph::toybase_individual_2016_03 %>%
25 | eph::organize_labels() %>%
26 | dplyr::filter(AGLOMERADO == 32) %>%
27 | calculate_tabulates(
28 | x = "CH03",
29 | weights = "PONDERA",
30 | add.totals = "row"
31 | )
32 |
33 | tabla_errors <- tabla %>%
34 | dplyr::mutate(cv = calculate_errors(Freq,
35 | codigo_aglo = "32",
36 | periodo_eph = "2014.03", measure = "cv"
37 | ))
38 |
39 | expect_equal(ncol(tabla_errors), 3)
40 | expect_equal(nrow(tabla_errors), nrow(tabla))
41 | expect_equal(tabla_errors[1, 3], 14.7)
42 | })
43 |
--------------------------------------------------------------------------------
/tests/testthat/test-calculate_poverty.R:
--------------------------------------------------------------------------------
1 | context("test-calculate_poverty")
2 |
3 |
4 | test_that("Test pobreza e indigencia trimestre", {
5 | base_pobreza <- calculate_poverty(base = eph::toybase_individual_2016_03,
6 | basket = canastas_reg_example,
7 | print_summary = FALSE)
8 |
9 | expect_equal(ncol(base_pobreza), 182)
10 |
11 | Pobreza_resumen <- base_pobreza %>%
12 | dplyr::group_by(ANO4, TRIMESTRE) %>%
13 | dplyr::summarise(
14 | Tasa_pobreza = sum(PONDIH[situacion %in% c("pobre", "indigente")], na.rm = TRUE) /
15 | sum(PONDIH, na.rm = TRUE),
16 | Tasa_indigencia = sum(PONDIH[situacion == "indigente"], na.rm = TRUE) /
17 | sum(PONDIH, na.rm = TRUE)
18 | )
19 |
20 | expect_equal(round(Pobreza_resumen$Tasa_pobreza[1], 2), 0.03)
21 | expect_equal(round(Pobreza_resumen$Tasa_indigencia[1], 2), 0.01)
22 | })
23 |
24 | test_that("Test pobreza e indigencia semestre", {
25 | bases <- dplyr::bind_rows(
26 | toybase_individual_2016_03,
27 | toybase_individual_2016_04
28 | )
29 |
30 | base_pobreza <- calculate_poverty(
31 | base = bases,
32 | basket = canastas_reg_example,
33 | print_summary = TRUE,
34 | group_vars = c(CH04, NIVEL_ED),
35 | window = "semestral"
36 | )
37 |
38 | expect_equal(ncol(base_pobreza), 182)
39 | expect_equal(nrow(base_pobreza), nrow(bases))
40 |
41 | Pobreza_resumen <- base_pobreza %>%
42 | dplyr::mutate(SEMESTRE = ifelse(TRIMESTRE %in% c(1, 2), yes = 1, no = 2)) %>%
43 | dplyr::group_by(ANO4, SEMESTRE, CH04, NIVEL_ED) %>%
44 | dplyr::summarise(
45 | Tasa_pobreza = sum(PONDIH[situacion %in% c("pobre", "indigente")], na.rm = TRUE) /
46 | sum(PONDIH, na.rm = TRUE),
47 | Tasa_indigencia = sum(PONDIH[situacion == "indigente"], na.rm = TRUE) /
48 | sum(PONDIH, na.rm = TRUE)
49 | )
50 |
51 | expect_equal(round(Pobreza_resumen$Tasa_pobreza[1], 2), 0.07)
52 | expect_equal(round(Pobreza_resumen$Tasa_indigencia[1], 4), 0.0043)
53 | })
54 |
--------------------------------------------------------------------------------
/tests/testthat/test-calculate_tabulates.R:
--------------------------------------------------------------------------------
1 | context("test-calculate_tabulates")
2 |
3 | ### descargo la base para el ejemplo ###
4 |
5 | test_that("tabla simple", {
6 | tab <- calculate_tabulates(base = toybase_individual_2016_03, x = "REGION", y = "CH04", weights = "PONDERA") %>% as.data.frame(.)
7 | expect_equal(tab[1, 2], 259235)
8 | })
9 |
10 | test_that("totales por fila", {
11 | tab <- calculate_tabulates(base = toybase_individual_2016_03, x = "REGION", y = "CH04", weights = "PONDERA", add.totals = "row") %>% as.data.frame(.)
12 | expect_equal(tab[nrow(tab), 2], 465265)
13 | })
14 |
15 | test_that("totales por columna", {
16 | tab <- calculate_tabulates(base = toybase_individual_2016_03, x = "REGION", y = "CH04", weights = "PONDERA", add.totals = "col") %>% as.data.frame(.)
17 | expect_equal(tab$Total[1], 514813)
18 | })
19 |
20 |
21 | test_that("porcentaje por fila", {
22 | tab <- calculate_tabulates(base = toybase_individual_2016_03, x = "REGION", y = "CH04", weights = "PONDERA", add.percentage = "row") %>% as.data.frame(.)
23 | expect_equal(tab[1, 2], 50.4)
24 | })
25 |
26 | test_that("porcentaje por columna", {
27 | tab <- calculate_tabulates(base = toybase_individual_2016_03, x = "REGION", y = "CH04", weights = "PONDERA", add.percentage = "col") %>% as.data.frame(.)
28 | expect_equal(tab[1, 2], 55.7)
29 | })
30 |
31 |
32 | test_that("affix", {
33 | tab <- calculate_tabulates(base = toybase_individual_2016_03, x = "REGION", y = "CH04", weights = "PONDERA", add.percentage = "col", affix_sign = TRUE) %>% as.data.frame(.)
34 | expect_equal(tab[1, 2], "55.7%")
35 | expect_equal(class(tab[, 2]), "character")
36 | })
37 |
38 | test_that("digits", {
39 | tab <- calculate_tabulates(base = toybase_individual_2016_03, x = "REGION", y = "CH04", weights = "PONDERA", add.percentage = "col", digits = 8, affix_sign = TRUE) %>% as.data.frame(.)
40 | expect_equal(tab[1, 2], "55.71770926%")
41 | expect_equal(class(tab[, 2]), "character")
42 | })
43 |
44 |
45 | test_that("tabulado univariado", {
46 | tab <- calculate_tabulates(base = toybase_individual_2016_03, x = "REGION", weights = "PONDERA") %>% as.data.frame(.)
47 | expect_equal(tab[1, 2], 514813)
48 | })
49 |
50 | test_that("tabulado univariado porcentaje fila", {
51 | tab <- calculate_tabulates(base = toybase_individual_2016_03, x = "REGION", weights = "PONDERA", add.percentage = "row") %>% as.data.frame(.)
52 | expect_equal(tab[1, 2], 100)
53 | })
54 |
55 | test_that("tabulado univariado porcentaje columna", {
56 | tab <- calculate_tabulates(base = toybase_individual_2016_03, x = "REGION", weights = "PONDERA", add.percentage = "col") %>% as.data.frame(.)
57 | expect_equal(tab[1, 2], 54.9)
58 | })
59 |
--------------------------------------------------------------------------------
/tests/testthat/test-get_eahu.R:
--------------------------------------------------------------------------------
1 | test_that("EAHU descarga", {
2 | skip_if_offline()
3 | skip_on_cran()
4 | df <- get_eahu(year = 2011, type = "individual", vars = "all")
5 | dimensiones <- dim(df)
6 | expect_equal(dimensiones, c(111950, 153))
7 | })
8 |
9 | test_that("selec variables", {
10 | skip_if_offline()
11 | skip_on_cran()
12 | df <- get_eahu(year = 2011, type = "individual", vars = c("CODUSU", "NRO_HOGAR", "CH04", "PONDERA"))
13 | dimensiones <- dim(df)
14 | expect_equal(dimensiones, c(111950, 4))
15 | })
16 |
17 | test_that("fuera de 2010/2014", {
18 | skip_if_offline()
19 | skip_on_cran()
20 | expect_warning(df <- get_eahu(year = 2009, type = "individual"))
21 | })
22 |
23 | test_that("errores", {
24 | expect_warning(df <- get_eahu(year = 2011, type = "individu"))
25 | })
26 |
--------------------------------------------------------------------------------
/tests/testthat/test-get_microdata.R:
--------------------------------------------------------------------------------
1 | context("test-get_microdata")
2 |
3 | test_that("EPH puntual", {
4 | skip_if_offline()
5 | skip_on_cran()
6 | df <- get_microdata(year = 1996, period = 1, vars = c("CODUSU", "AGLOMERADO", "IPCF"))
7 | dimensiones <- dim(df)
8 | expect_equal(dimensiones, c(113209, 3))
9 | })
10 |
11 |
12 | test_that("EPH continua", {
13 | skip_if_offline()
14 | skip_on_cran()
15 | expect_warning(df <- get_microdata(year = 2015, period = 2, vars = c("PONDERA", "ESTADO", "CAT_OCUP")))
16 | dimensiones <- dim(df)
17 | expect_equal(dimensiones, c(60028, 3))
18 | })
19 |
20 |
21 | test_that("Sin data", {
22 | skip_if_offline()
23 | expect_warning(df <- get_microdata(year = 2015, period = 4))
24 | expect_length(df, 0)
25 | })
26 |
27 | # test_that("muchas bases", {
28 | # skip_if_offline()
29 | # skip_on_cran()
30 | # df <- suppressWarnings(get_microdata(year = 2017:2018, period = 4,type = c('individual','hogar')))
31 | # expect_equal(dim(df$microdata[[1]]), c(58181,177))
32 | # expect_equal(dim(df$microdata[[2]]), c(57418,177))
33 | # expect_equal(dim(df$microdata[[3]]), c(18793,88))
34 | # expect_equal(dim(df$microdata[[4]]), c(18616,88))
35 | # })
36 |
--------------------------------------------------------------------------------
/tests/testthat/test-get_poverty_lines.R:
--------------------------------------------------------------------------------
1 | context("test-get_poverty_lines")
2 |
3 | test_that("test GBA", {
4 | skip_if_offline()
5 | canasta <- get_poverty_lines()
6 | expect_equal(canasta$CBA[1], 1514.53)
7 | expect_equal(canasta$ICE[1], 2.42)
8 | expect_equal(canasta$CBT[1], 3663.66)
9 | })
10 |
11 | test_that("test regiones", {
12 | skip_if_offline()
13 | canasta <- get_poverty_lines(regional = TRUE)
14 | expect_equal(canasta$CBA[1], 1224.64)
15 | expect_equal(unique(canasta$region), c("Cuyo", "GBA", "Noreste", "Noroeste", "Pampeana", "Patagonia"))
16 | })
17 |
--------------------------------------------------------------------------------
/tests/testthat/test-get_total_urbano.R:
--------------------------------------------------------------------------------
1 | test_that("selec variables", {
2 | skip_if_offline()
3 | skip_on_cran()
4 | df <- get_total_urbano(year = 2016, type = "individual", vars = c("CODUSU", "CH04", "CH06", "PONDERA"))
5 | dimensiones <- dim(df)
6 | expect_equal(dimensiones, c(95782, 4))
7 | })
8 |
9 | test_that("antes de 2016", {
10 | skip_if_offline()
11 | skip_on_cran()
12 | expect_warning(df <- get_total_urbano(year = 2009, type = "individual"))
13 | })
14 |
15 | test_that("errores", {
16 | expect_warning(df <- get_total_urbano(year = 2016, type = "individu"))
17 | })
18 |
--------------------------------------------------------------------------------
/tests/testthat/test-is_in_github.R:
--------------------------------------------------------------------------------
1 | httptest::without_internet({
2 | test_that("Requests happen", {
3 | skip_on_cran()
4 | httptest::expect_GET(httr::GET("https://api.github.com/repos/holatam/data/git/trees/master?recursive=1"))
5 | })
6 | })
7 |
8 | httptest::with_mock_dir("is_in_github",{
9 | test_that("Requests work", {
10 | skip_on_cran()
11 | testthat::expect_type(is_in_github(), "logical")
12 | })
13 | })
14 |
--------------------------------------------------------------------------------
/tests/testthat/test-map_agglomerates.R:
--------------------------------------------------------------------------------
1 | context("test-map_agglomerates")
2 |
3 | test_that("mapeo tabla simple", {
4 | mapa <- toybase_individual_2016_04 %>%
5 | dplyr::group_by(AGLOMERADO) %>%
6 | dplyr::summarise(tasa_actividad = sum(PONDERA[ESTADO == 1]) / sum(PONDERA)) %>%
7 | map_agglomerates(agglomerates = AGLOMERADO, indicator = tasa_actividad)
8 |
9 | expect_equal(class(mapa), c("leaflet", "htmlwidget"))
10 | expect_equal(dim(attributes(mapa$x)$leafletData), c(32,5))
11 | expect_equal(mapa$sizingPolicy$defaultWidth, "100%")
12 | expect_equal(mapa$sizingPolicy$defaultHeight, 400)
13 | expect_equal(mapa$sizingPolicy$viewer$fill, TRUE)
14 | expect_equal(mapa$sizingPolicy$knitr$figure, TRUE)
15 | })
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/tests/testthat/test-organize_caes.R:
--------------------------------------------------------------------------------
1 | context("test-organize_caes")
2 |
3 | test_that("checkear shape", {
4 | bases <- suppressWarnings(dplyr::bind_rows(toybase_individual_2016_03, toybase_individual_2016_04))
5 | expect_warning(bases_caes <- bases %>% organize_caes())
6 | expect_equal(ncol(bases_caes), 185)
7 | })
8 |
--------------------------------------------------------------------------------
/tests/testthat/test-organize_cno.R:
--------------------------------------------------------------------------------
1 | test_that("checkear shape", {
2 | bases <- suppressWarnings(dplyr::bind_rows(toybase_individual_2016_03, toybase_individual_2016_04))
3 | bases_cno <- bases %>% organize_cno()
4 | expect_equal(ncol(bases_cno), 181)
5 | })
6 |
--------------------------------------------------------------------------------
/tests/testthat/test-organize_labels.R:
--------------------------------------------------------------------------------
1 | context("test-organize_labels")
2 |
3 | test_that("labels hogar", {
4 | df <- organize_labels(toybase_hogar_2016_04, type = "hogar")
5 | regiones <- expss::val_lab(df$REGION)
6 | expect_equal(!is.null(regiones), TRUE)
7 | })
8 |
9 |
10 | test_that("labels individual", {
11 | df <- organize_labels(toybase_individual_2016_03, type = "individual")
12 | regiones <- expss::val_lab(df$REGION)
13 | expect_equal(!is.null(regiones), TRUE)
14 | })
15 |
--------------------------------------------------------------------------------
/tests/testthat/test-organize_panels.R:
--------------------------------------------------------------------------------
1 | context("test-organize_panels")
2 |
3 | test_that("consistencia constante", {
4 | lista_bases <- list(toybase_individual_2016_03, toybase_individual_2016_04)
5 | pool_trimestral <- suppressWarnings(organize_panels(
6 | bases = lista_bases,
7 | variables = c("P21", "ESTADO"),
8 | window = "trimestral"
9 | ))
10 |
11 | expect_equal(round(sum(pool_trimestral$consistencia) / nrow(pool_trimestral), 2), 0.97)
12 | })
13 |
--------------------------------------------------------------------------------
/vignettes/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 | *.R
3 |
--------------------------------------------------------------------------------