Skip to content

Commit

Permalink
1960 census
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapereirabr committed Sep 18, 2024
1 parent 6b49757 commit 179438f
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 4 deletions.
10 changes: 9 additions & 1 deletion R/read_households.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#' @template cache
#'
#' @return An arrow `Dataset` or a `"data.frame"` object.
#'
#' @template 1960_census_section
#'
#' @export
#' @family Microdata
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true")
Expand All @@ -34,7 +37,7 @@ read_households <- function(year = 2010,
checkmate::assert_string(add_labels, pattern = 'pt', null.ok = TRUE)

# data available for the years:
years <- c(1970, 1980, 1991, 2000, 2010)
years <- c(1960, 1970, 1980, 1991, 2000, 2010)
if (isFALSE(year %in% years)) { stop(paste0("Error: Data currently only available for the years ",
paste(years, collapse = " ")))}

Expand Down Expand Up @@ -67,6 +70,11 @@ read_households <- function(year = 2010,
lang = add_labels)
}

# 1960 warning
if(year==1960){
warning("This version of the 1960 microdata was compiled by {censobr} from two different releases elaborated by IBGE. The data was processed to ensure consistency and new variables added. See the documentation")
}

### output format
if (isTRUE(as_data_frame)) { return( dplyr::collect(df) )
} else {
Expand Down
10 changes: 9 additions & 1 deletion R/read_population.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#' @template cache
#'
#' @return An arrow `Dataset` or a `"data.frame"` object.
#'
#' @template 1960_census_section
#'
#' @export
#' @family Microdata
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true")
Expand All @@ -35,7 +38,7 @@ read_population <- function(year = 2010,
checkmate::assert_string(add_labels, pattern = 'pt', null.ok = TRUE)

# data available for the years:
years <- c(1970, 1980, 1991, 2000, 2010)
years <- c(1960, 1970, 1980, 1991, 2000, 2010)
if (isFALSE(year %in% years)) { stop(paste0("Error: Data currently only available for the years ",
paste(years, collapse = " ")))}

Expand Down Expand Up @@ -76,6 +79,11 @@ read_population <- function(year = 2010,
lang = add_labels)
}

# 1960 warning
if(year==1960){
warning("This version of the 1960 microdata was compiled by {censobr} from two different releases elaborated by IBGE. The data was processed to ensure consistency and new variables added. See the documentation")
}

### output format
if (isTRUE(as_data_frame)) { return( dplyr::collect(df) )
} else {
Expand Down
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## R CMD check results

── R CMD check results ────────────────────────────── censobr 0.3.9999999 ────
Duration: 5m 52.9s
── R CMD check results ──────────────────────────────── censobr 0.3.29999 ────
Duration: 10m 48.6s

0 errors ✔ | 0 warnings ✔ | 0 notes ✔

Expand Down
28 changes: 28 additions & 0 deletions man/read_households.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions man/read_population.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions man/roxygen/templates/1960_census_section.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#' @section 1960 Census:
#'
#'The 1960 microdata version available in **{censobr}** is a combination of two
#'versions of the Demographic Census sample. The 25% sample data from the 1960
#'Census was never fully processed by IBGE - several states did not have their
#'questionnaires digitized. Currently, this dataset only has data from 16 states
#'of the Federation (and from a contested border region between Minas Gerais and
#'Espirito Santo called Serra dos Aimores). Information is missing for the states
#'of the former Northern Region, Maranhão, Piaui, Guanabara, Santa Catarina, and
#'Espírito Santo. In 1965, IBGE decided to draw a probabilistic sub-sample of
#'approximately 1.27% of the population, including all units of the federation.
#'With this data, IBGE produced several official reports at the time. The data
#'from **{censobr}** is the combination of these two datasets.
#'
#'We processed and ensured the consistency of the 1.27% sample data, which was
#'partially corrupted. We also created a sample weight variable to correct for
#'disproportionalities and to expand te sample to the total population. For the
#'data from the 25% sample, the weights expand to the municipal totals.
#'Meanwhile, for the data from the 1.27% sample, the weights expand to the state
#'totals. Additionally, we constructed a few variables that allow for the
#'approximate incorporation of the complex sample design, enabling the proper
#'calculation of standard errors and confidence intervals.
#'
#'You can read more about the 1960 Census and find a thogorugh documentation of
#'how this dataset was processed on this link \url{https://github.com/antrologos/ConsistenciaCenso1960Br}.

0 comments on commit 179438f

Please sign in to comment.