Skip to content

Commit

Permalink
version 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapereirabr authored and cran-robot committed Sep 6, 2023
0 parents commit f3d9db4
Show file tree
Hide file tree
Showing 53 changed files with 4,211 additions and 0 deletions.
34 changes: 34 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Type: Package
Package: censobr
Title: Download Data from Brazil's Population Census
Version: 0.1.0
Authors@R:
c(person(given="Rafael H. M.", family="Pereira",
email="rafa.pereira.br@gmail.com",
role=c("aut", "cre"),
comment = c(ORCID = "0000-0003-2125-7465")),
person(given = "Ipea - Institute for Applied Economic Research",
role = c("cph", "fnd")))
Description: Download data from Brazil's population census. The package is built
on top of the 'Arrow' platform <https://arrow.apache.org/docs/r/>,
which allows users to work with larger-than-memory census data using
'dplyr' familiar functions. <https://arrow.apache.org/docs/r/articles/arrow.html#analyzing-arrow-data-with-dplyr>.
License: MIT + file LICENSE
URL: https://github.com/ipeaGIT/censobr,
https://ipeagit.github.io/censobr/
BugReports: https://github.com/ipeaGIT/censobr/issues
Depends: R (>= 4.0)
Imports: arrow, checkmate, dplyr, httr (>= 1.4.1), tools
Suggests: covr, geobr, ggplot2 (>= 3.3.1), rmarkdown (>= 2.6), knitr,
scales, testthat
VignetteBuilder: knitr
Encoding: UTF-8
NeedsCompilation: yes
RoxygenNote: 7.2.3
Packaged: 2023-09-05 18:46:04 UTC; user
Author: Rafael H. M. Pereira [aut, cre]
(<https://orcid.org/0000-0003-2125-7465>),
Ipea - Institute for Applied Economic Research [cph, fnd]
Maintainer: Rafael H. M. Pereira <rafa.pereira.br@gmail.com>
Repository: CRAN
Date/Publication: 2023-09-06 17:50:05 UTC
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2023
COPYRIGHT HOLDER: Ipea
52 changes: 52 additions & 0 deletions MD5
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
9e1528d98491a1229fa18b51cdbbe75a *DESCRIPTION
3e30d3756ddb8c51acc9c524103f5e79 *LICENSE
951e46f3c22cb623bfec077bbdfa1daf *NAMESPACE
6e9ebd22224344bbcdebcc706244f72a *NEWS.md
6072c9d9fe367166bf84887f523e3de2 *R/add_labels_emigration.R
714e936337c2a47311721677b377290a *R/add_labels_families.R
714cef6ea97b0d23e8eae02ffc35f397 *R/add_labels_households.R
085e492fb8c65f21b4dac905440bbad0 *R/add_labels_mortality.R
460107a764726638e45f28380395e400 *R/add_labels_population.R
7023dd836734ff428b953874fe2874f0 *R/censobr.R
0d765e212529b76c56c9d4772aaceae7 *R/censobr_cache.R
707e04233c86afd39ba09bd6d94d0520 *R/read_emigration.R
5d97a106754ac92199e87a27c89aa95a *R/read_families.R
1d4c45499e3b71888704f55206503693 *R/read_households.R
3352c981817e7e18ba04912ae92529a2 *R/read_mortality.R
5bc51e4b3510ea44a1f49b6f383a7f44 *R/read_population.R
290257a55583c92dd6f18678a607ce40 *R/utils.R
625b4ed8766778b756d4e05b3498ceb4 *README.md
6d27e6f80558fd5db0d3119ba75b99d4 *build/vignette.rds
318421dd44b22229f75f58fe4a0858bc *inst/doc/censobr.R
9827d783f7348e793e8ae7d40e5d32ac *inst/doc/censobr.Rmd
6aeafc85f83c99ba5e3edb1f4d7fcc3a *inst/doc/censobr.html
f28e5663dfcdd5d7274e1504032cf9f5 *inst/img/vig_output_pop1.png
1b48e3117c78dc490ca54081b9231ef5 *man/cache_message.Rd
36c6751d3e0287ef94deb7ed708caa5d *man/censobr.Rd
8c80c6bd5758433cea8519d237967a1e *man/censobr_cache.Rd
248aa9b96723be11c43ad41a71ed05c0 *man/download_file.Rd
b99bafee7c0cc94c8cf6b0f409bc3499 *man/figures/censobr_hexsticker.R
48219fca1ec818a8f49f1fd7b04efc68 *man/figures/ipea_logo.png
58bce978de1ff44ddff45c565fe6e4e2 *man/figures/logo.png
4b2af118a659294ac2cf09051d69970d *man/figures/person_icon.xcf
0122f64d230ba374dad15f0cf2f413f7 *man/figures/person_icon_white.png
311fe2b1071e6753e12e4049bf9bf1d4 *man/read_emigration.Rd
359305937fca359f05a49e177c83e7b7 *man/read_families.Rd
e3969e8f7dbbf1a7e80b35057c745eee *man/read_households.Rd
1ee3a11f431d0af0bb219daa91d26846 *man/read_mortality.Rd
050edfc04e92cc2fb897038b93ebc1de *man/read_population.Rd
612385be109e4192883eb7f8aa849c87 *man/roxygen/templates/add_labels.R
d5d889932073de579e60949cd9f841d0 *man/roxygen/templates/as_data_frame.R
1eee990802cf2b626122a37d1807c6d0 *man/roxygen/templates/cache.R
ae2ba005e0f39daa9c2dc28b9818ce78 *man/roxygen/templates/columns.R
d4d9d9cd6cc072a6d02469509b649dd5 *man/roxygen/templates/showProgress.R
82201c1a3cba4093e9246c6a630100e4 *man/roxygen/templates/year.R
8a419b0d2f8c6e081ffb7825bbe59a7f *tests/tests_rafa/test_rafa.R
cc349a47c388a49a388f296f48b3ec52 *tests/testthat.R
0c76a2bd213e8255722b3b20471201c6 *tests/testthat/test_censobr_cache.R
ef37b8cf6cd856877153b8050694d02f *tests/testthat/test_read_emigration.R
90276ef02d7923225248d23f2fd5f1e3 *tests/testthat/test_read_families.R
167fd72ec96af6088abe3d4c25f5e3ed *tests/testthat/test_read_households.R
447e2c51e641fd2a89b323ff92d12517 *tests/testthat/test_read_mortality.R
fdbb4006ba53267b8b1a0bc1d7de6a66 *tests/testthat/test_read_population.R
9827d783f7348e793e8ae7d40e5d32ac *vignettes/censobr.Rmd
13 changes: 13 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by roxygen2: do not edit by hand

export(censobr_cache)
export(read_emigration)
export(read_families)
export(read_households)
export(read_mortality)
export(read_population)
importFrom(dplyr,across)
importFrom(dplyr,all_of)
importFrom(dplyr,case_when)
importFrom(dplyr,mutate)
importFrom(dplyr,select)
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# censobr v0.1.0

* Launch of **censobr** v0.1.0 on CRAN https://cran.r-project.org/package=censobr
* All data sets are now enriched with geography columns following {geobr} name standards. This should help data manipulation and integration with spatial data from the [{geobr}](https://github.com/ipeaGIT/geobr) package. The added columns are: c('code_muni', 'code_state', 'abbrev_state', 'name_state', 'code_region', 'name_region', 'code_weighting'). Closes #5.
* Data included in this version:
* 2000 Census
* Microdata of population, households and families.
* 2010 Census
* Microdata of population, households, deaths and emigration.
251 changes: 251 additions & 0 deletions R/add_labels_emigration.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
# Add labels to categorical variables of emigration datasets
#' @keywords internal
add_labels_emigration <- function(arrw,
year = parent.frame()$year,
lang = 'pt'){

# check languate input
checkmate::assert_string(lang, pattern = 'pt', na.ok = TRUE)

# names of columns present in the data
cols <- names(arrw)

### YEAR 2010
if(year == 2010 & lang == 'pt'){


# urban vs rural
if ('V1006' %in% cols) {
arrw <- arrw |> mutate(V1006 = case_when(
V1006 == '1' ~'Urbana',
V1006 == '2' ~'Rural'))
}

# sex of emmigrant
if ('V0303' %in% cols) {
arrw <- arrw |> mutate(V0303 = case_when(
V0303 == '1' ~ 'Masculino',
V0303 == '2' ~ 'Feminino',
V0303== '9' ~ 'Ignorado'))
}

# census tract type
if ('V1005' %in% cols) {
arrw <- arrw |> mutate(V1005 = case_when(
V1005 == '1' ~ paste0('\u00c1rea urbanizada'),
V1005 == '2' ~ paste0('\u00c1rea n\u00e3o urbanizada'),
V1005 == '3' ~ paste0('\u00c1rea urbanizada isolada'),
V1005 == '4' ~ paste0('\u00c1rea rural de extens\u00e3o urbana'),
V1005 == '5' ~ 'Aglomerado rural (povoado)',
V1005 == '6' ~ paste0('Aglomerado rural (n\u00facleo)'),
V1005 == '7' ~ 'Aglomerado rural (outros)',
V1005 == '8' ~ paste0('\u00c1rea rural exclusive aglomerado rural')))
}

# country of residence
if ('V3061' %in% cols) {
arrw <- arrw |> mutate(V3061 = case_when(
V3061 == '8000710' ~ paste0('\u00c1frica do SUL'),
V3061 == '8000024' ~ 'Angola',
V3061 == '8000012' ~ paste0('Arg\u00e9lia'),
V3061 == '8000204' ~ 'Benin',
V3061 == '8000072' ~ 'Botswana',
V3061 == '8000854' ~ 'Burkina Fasso',
V3061 == '8000108' ~ 'Burundi',
V3061 == '8000132' ~ 'Cabo Verde',
V3061 == '8000120' ~ paste0('Camar\u00f5es'),
V3061 == '8000148' ~ 'Chade',
V3061 == '8000174' ~ 'Comores',
V3061 == '8000178' ~ 'Congo',
V3061 == '8000384' ~ 'Costa do Marfim',
V3061 == '8000262' ~ 'Djibuti',
V3061 == '8000818' ~ 'Egito',
V3061 == '8000232' ~ paste0('Eritr\u00e9ia'),
V3061 == '8000231' ~ paste0('Eti\u00f3pia'),
V3061 == '8000266' ~ paste0('Gab\u00e3o'),
V3061 == '8000270' ~ paste0('G\u00e2mbia'),
V3061 == '8000288' ~ paste0('Gana'),
V3061 == '8000324' ~ paste0('Guin\u00e9'),
V3061 == '8000624' ~ paste0('Guin\u00e9 Bissau'),
V3061 == '8000226' ~ paste0('Guin\u00e9 Equatorial'),
V3061 == '8000426' ~ 'Lesoto',
V3061 == '8000430' ~ paste0('Lib\u00e9ria'),
V3061 == '8000434' ~ paste0('L\u00edbia'),
V3061 == '8000450' ~ 'Madagascar',
V3061 == '8000454' ~ 'Malawi',
V3061 == '8000466' ~ 'Mali',
V3061 == '8000504' ~ 'Marrocos',
V3061 == '8000480' ~ paste0('Maur\u00edcio'),
V3061 == '8000478' ~ paste0('Maurit\u00e2nia'),
V3061 == '8000508' ~ paste0('Mo\u00e7ambique'),
V3061 == '8000516' ~ paste0('Nam\u00edbia'),
V3061 == '8000562' ~ 'Niger',
V3061 == '8000566' ~ paste0('Nig\u00e9ria'),
V3061 == '8000404' ~ paste0('Qu\u00eania'),
V3061 == '8000140' ~ paste0('Rep\u00fablica Centro Africana'),
V3061 == '8000180' ~ paste0('Rep\u00fablica Democr\u00e1tica do Congo'),
V3061 == '8000646' ~ 'Ruanda',
V3061 == '8000678' ~ paste0('S\u00e3o Tom\u00e9 e Pr\u00edncipe'),
V3061 == '8000686' ~ 'Senegal',
V3061 == '8000694' ~ 'Serra Leoa',
V3061 == '8000690' ~ 'Seychelles',
V3061 == '8000706' ~ paste0('Som\u00e1lia'),
V3061 == '8000748' ~ paste0('Suazil\u00e2ndia'),
V3061 == '8000736' ~ paste0('Sud\u00e3o'),
V3061 == '8000834' ~ paste0('Tanz\u00e2nia'),
V3061 == '8000768' ~ 'Togo',
V3061 == '8000788' ~ paste0('Tun\u00edsia'),
V3061 == '8000800' ~ paste0('Uganda'),
V3061 == '8000894' ~ paste0('Z\u00e2mbia'),
V3061 == '8000716' ~ paste0('Zimbabue'),
V3061 == '8000028' ~ paste0('Ant\u00edgua e Barbuda'),
V3061 == '8000032' ~ 'Argentina',
V3061 == '8000044' ~ 'Bahamas',
V3061 == '8000052' ~ 'Barbados',
V3061 == '8000084' ~ 'Belize',
V3061 == '8000068' ~ paste0('Bol\u00edvia'),
V3061 == '8000124' ~ paste0('Canad\u00e1'),
V3061 == '8000152' ~ paste0('Chile'),
V3061 == '8000170' ~ paste0('Col\u00f4mbia'),
V3061 == '8000188' ~ 'Costa Rica',
V3061 == '8000192' ~ 'Cuba',
V3061 == '8000212' ~ 'Dominica',
V3061 == '8000222' ~ 'El Salvador',
V3061 == '8000218' ~ 'Equador',
V3061 == '8000840' ~ 'Estados Unidos',
V3061 == '8000308' ~ 'Granada',
V3061 == '8000320' ~ 'Guatemala',
V3061 == '8000328' ~ 'Guiana',
V3061 == '8000254' ~ 'Guiana Francesa',
V3061 == '8000332' ~ 'Haiti',
V3061 == '8000340' ~ 'Honduras',
V3061 == '8000388' ~ 'Jamaica',
V3061 == '8000484' ~ paste0('M\u00e9xico'),
V3061 == '8000558' ~ paste0('Nicar\u00e1gua'),
V3061 == '8000591' ~ paste0('Panam\u00e1'),
V3061 == '8000600' ~ paste0('Paraguai'),
V3061 == '8000604' ~ paste0('Peru'),
V3061 == '8000214' ~ paste0('Rep\u00fablica Dominicana'),
V3061 == '8000662' ~ paste0('Santa L\u00facia'),
V3061 == '8000659' ~ paste0('S\u00e3o Crist\u00f3v\u00e3o e Nevis'),
V3061 == '8000670' ~ 'Sao Vicente e Granadinas',
V3061 == '8000740' ~ 'Suriname',
V3061 == '8000780' ~ 'Trinidad e Tobago',
V3061 == '8000858' ~ 'Uruguai',
V3061 == '8000862' ~ 'Venezuela',
V3061 == '8000004' ~ paste0('Afeganist\u00e3o'),
V3061 == '8000682' ~ paste0('Ar\u00e1bia Saudita'),
V3061 == '8000051' ~ paste0('Arm\u00eania'),
V3061 == '8000031' ~ paste0('Azerbaidj\u00e3o'),
V3061 == '8000048' ~ 'Bahrein',
V3061 == '8000050' ~ 'Bangladesh',
V3061 == '8000096' ~ 'Brunei Darussalan',
V3061 == '8000064' ~ paste0('But\u00e3o'),
V3061 == '8000116' ~ 'Camboja',
V3061 == '8000398' ~ paste0('Casaquist\u00e3o'),
V3061 == '8000634' ~ 'Catar',
V3061 == '8000156' ~ 'China',
V3061 == '8000196' ~ 'Chipre',
V3061 == '8000702' ~ 'Cingapura',
V3061 == '8000784' ~ paste0('Emirados \u00c1rabes Unidos'),
V3061 == '8000608' ~ paste0('Filipinas'),
V3061 == '8000268' ~ paste0('Ge\u00f3rgia'),
V3061 == '8000887' ~ paste0('I\u00eamen'),
V3061 == '8000356' ~ paste0('\u00cdndia'),
V3061 == '8000360' ~ paste0('Indon\u00e9sia'),
V3061 == '8000364' ~ paste0('Ir\u00e3'),
V3061 == '8000368' ~ paste0('Iraque'),
V3061 == '8000376' ~ paste0('Israel'),
V3061 == '8000392' ~ paste0('Jap\u00e3o'),
V3061 == '8000400' ~ paste0('Jord\u00e2nia'),
V3061 == '8000414' ~ paste0('Kuwait'),
V3061 == '8000422' ~ paste0('L\u00edbano'),
V3061 == '8000458' ~ paste0('Mal\u00e1sia'),
V3061 == '8000462' ~ 'Maldivas',
V3061 == '8000104' ~ 'Mianmar',
V3061 == '8000496' ~ paste0('Mong\u00f3lia'),
V3061 == '8000524' ~ 'Nepal',
V3061 == '8000512' ~ 'Oman',
V3061 == '8000586' ~ paste0('Paquist\u00e3o'),
V3061 == '8000417' ~ paste0('Quirguist\u00e3o'),
V3061 == '8000410' ~ paste0('Rep\u00fablica da Coreia'),
V3061 == '8000418' ~ paste0('Rep\u00fablica Democr\u00e1tica Popular do Laos'),
V3061 == '8000408' ~ paste0('Rep\u00fablica Popular Democr\u00e1tica da Coreia'),
V3061 == '8000760' ~ paste0('S\u00edria'),
V3061 == '8000144' ~ paste0('Sri Lanka'),
V3061 == '8000762' ~ paste0('Tadjiquist\u00e3o'),
V3061 == '8000764' ~ paste0('Tail\u00e2ndia'),
V3061 == '8000626' ~ paste0('Timor Leste'),
V3061 == '8000795' ~ paste0('Turcomenist\u00e3o'),
V3061 == '8000792' ~ paste0('Turquia'),
V3061 == '8000860' ~ paste0('Uzbequist\u00e3o'),
V3061 == '8000704' ~ paste0('Vietn\u00e3'),
V3061 == '8000008' ~ paste0('Alb\u00e2nia'),
V3061 == '8000276' ~ paste0('Alemanha'),
V3061 == '8000020' ~ paste0('Andorra'),
V3061 == '8000040' ~ paste0('\u00c1ustria'),
V3061 == '8000112' ~ paste0('Belarus'),
V3061 == '8000056' ~ paste0('B\u00e9lgica'),
V3061 == '8000070' ~ paste0('B\u00f3snia e Herzegovina'),
V3061 == '8000100' ~ paste0('Bulg\u00e1ria'),
V3061 == '8000191' ~ paste0('Cro\u00e1cia'),
V3061 == '8000208' ~ paste0('Dinamarca'),
V3061 == '8000826' ~ paste0('Esc\u00f3cia'),
V3061 == '8000703' ~ paste0('Eslov\u00e1quia'),
V3061 == '8000705' ~ paste0('Eslov\u00eania'),
V3061 == '8000724' ~ paste0('Espanha'),
V3061 == '8000233' ~ paste0('Est\u00f4nia'),
V3061 == '8000246' ~ paste0('Finl\u00e2ndia'),
V3061 == '8000250' ~ paste0('Fran\u00e7a'),
V3061 == '8000300' ~ paste0('Gr\u00e9cia'),
V3061 == '8000528' ~ 'Holanda',
V3061 == '8000348' ~ 'Hungria',
V3061 == '8000826' ~ 'Inglaterra',
V3061 == '8000372' ~ 'Irlanda',
V3061 == '8000826' ~ 'Irlanda do Norte',
V3061 == '8000352' ~ paste0('Isl\u00e2ndia'),
V3061 == '8000380' ~ paste0('It\u00e1lia'),
V3061 == '8000428' ~ paste0('Let\u00f4nia'),
V3061 == '8000438' ~ paste0('Liechtenstein'),
V3061 == '8000440' ~ paste0('Litu\u00e2nia'),
V3061 == '8000442' ~ paste0('Luxemburgo'),
V3061 == '8000807' ~ paste0('Maced\u00f4nia'),
V3061 == '8000470' ~ paste0('Malta'),
V3061 == '8000492' ~ paste0('M\u00f4naco'),
V3061 == '8000499' ~ 'Montenegro',
V3061 == '8000578' ~ 'Noruega',
V3061 == '8000826' ~ paste0('Pa\u00eds de gales'),
V3061 == '8000616' ~ paste0('Pol\u00f4nia'),
V3061 == '8000620' ~ paste0('Portugal'),
V3061 == '8000826' ~ paste0('Reino Unido'),
V3061 == '8000498' ~ paste0('Rep\u00fablica da Moldavia'),
V3061 == '8000203' ~ paste0('Rep\u00fablica Tcheca'),
V3061 == '8000642' ~ paste0('Rom\u00eania'),
V3061 == '8000643' ~ paste0('R\u00fassia'),
V3061 == '8000674' ~ paste0('San Marino'),
V3061 == '8000688' ~ paste0('S\u00e9rvia'),
V3061 == '8000752' ~ paste0('Su\u00e9cia'),
V3061 == '8000756' ~ paste0('Su\u00ed\u00e7a'),
V3061 == '8000804' ~ paste0('Ucr\u00e2nia'),
V3061 == '8000336' ~ paste0('Vaticano'),
V3061 == '8000036' ~ paste0('Austr\u00e1lia'),
V3061 == '8000583' ~ paste0('Federa\u00e7\u00e3o dos Estados da Micron\u00e9sia'),
V3061 == '8000242' ~ 'Fiji',
V3061 == '8000584' ~ 'Ilhas Marshall',
V3061 == '8000090' ~ paste0('Ilhas Salom\u00e3o'),
V3061 == '8000296' ~ 'Kiribati',
V3061 == '8000520' ~ 'Nauru',
V3061 == '8000554' ~ paste0('Nova Zel\u00e2ndia'),
V3061 == '8000585' ~ 'Palau',
V3061 == '8000598' ~ paste0('Papua Nova Guin\u00e9'),
V3061 == '8000882' ~ 'Samoa',
V3061 == '8000776' ~ 'Tonga',
V3061 == '8000798' ~ 'Tuvalu',
V3061 == '8000548' ~ 'Vanuatu',
V3061 == '8000998' ~ 'Ignorado',
V3061 == '8000999' ~ paste0('N\u00e3o sabia pa\u00eds estrangeiro')))
}
}

return(arrw)
}

0 comments on commit f3d9db4

Please sign in to comment.