Skip to content

Commit

Permalink
Merge pull request #21 from ipeaGIT/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rafapereirabr committed Sep 13, 2023
2 parents febc682 + 509e92b commit a735364
Show file tree
Hide file tree
Showing 32 changed files with 2,891 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: censobr
Title: Download Data from Brazil's Population Census
Version: 0.1.1
Version: 0.1.19000
Authors@R:
c(person(given="Rafael H. M.", family="Pereira",
email="rafa.pereira.br@gmail.com",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(censobr_cache)
export(data_dictionary)
export(read_emigration)
export(read_families)
export(read_households)
Expand Down
9 changes: 5 additions & 4 deletions tests/tests_rafa/data_dictionary.R → R/data_dictionary.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#' @param table Character. The table of data dictionary to be opened. Options
#' include `c("microdata")`.
#'
#' @return Opens .html file in browser
#' @return Opens .html file on browser
#' @export
#' @family Data Dictionary
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true")
#' # Open data dictionary on browser
#' read_mortality(year = 2010, table = 'microdata')
#' data_dictionary(year = 2010, table = 'microdata')
#'
data_dictionary <- function(year = NULL,
table = NULL){
Expand All @@ -24,7 +24,7 @@ data_dictionary <- function(year = NULL,
checkmate::assert_string(table)

# data available for the years:
years <- c(2010)
years <- c(2000, 2010)
if (isFALSE(year %in% years)) { stop( paste0("Error: Dictionary currently only available for the years: ",
paste(years), collapse = " ")
)}
Expand All @@ -40,9 +40,10 @@ data_dictionary <- function(year = NULL,
data_path <- system.file("extdata", package = "censobr")
all_dic <- list.files(data_path, full.names = TRUE, pattern = '.html')

# filter data dic by year and type of data
temp_dic <- all_dic[grepl(year, all_dic)]
temp_dic <- temp_dic[grepl(table, temp_dic)]

# open data dic on browser
utils::browseURL(url = temp_dic)

}
10 changes: 8 additions & 2 deletions R/read_emigration.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
#' @family Microdata
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true")
#' # return data as arrow Dataset
#' df <- read_emigration(year = 2010)
#' df <- read_emigration(year = 2010,
#' showProgress = FALSE)
#'
#' head(df) |> dplyr::collect()
#'
#' # return data as data.frame
#' df <- read_emigration(year = 2010, as_data_frame = TRUE)
#' df <- read_emigration(year = 2010,
#' as_data_frame = TRUE,
#' showProgress = FALSE)
#' head(df)
#'
read_emigration <- function(year = 2010,
columns = NULL,
Expand Down
5 changes: 4 additions & 1 deletion R/read_families.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
#' @family Microdata
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true")
#' # return data as arrow Dataset
#' df <- read_families(year = 2000)
#' df <- read_families(year = 2000,
#' showProgress = FALSE)
#'
#' head(df) |> dplyr::collect()
#'
read_families <- function(year = 2000,
columns = NULL,
Expand Down
3 changes: 2 additions & 1 deletion R/read_households.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#' @family Microdata
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true")
#' # return data as arrow Dataset
#' df <- read_households(year = 2010)
#' df <- read_households(year = 2010, showProgress = FALSE)
#' head(df) |> dplyr::collect()
#'
read_households <- function(year = 2010,
columns = NULL,
Expand Down
10 changes: 8 additions & 2 deletions R/read_mortality.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
#' @family Microdata
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true")
#' # return data as arrow Dataset
#' df <- read_mortality(year = 2010)
#' df <- read_mortality(year = 2010,
#' showProgress = FALSE)
#'
#' head(df) |> dplyr::collect()
#'
#' # return data as data.frame
#' df <- read_mortality(year = 2010, as_data_frame = TRUE)
#' df <- read_mortality(year = 2010,
#' as_data_frame = TRUE,
#' showProgress = FALSE)
#' head(df)
#'
read_mortality <- function(year = 2010,
columns = NULL,
Expand Down
5 changes: 4 additions & 1 deletion R/read_population.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
#' @family Microdata
#' @examplesIf identical(tolower(Sys.getenv("NOT_CRAN")), "true")
#' # return data as arrow Dataset
#' df <- read_population(year = 2010)
#' df <- read_population(year = 2010,
#' showProgress = FALSE)
#'
#' head(df) |> dplyr::collect()
#'
read_population <- function(year = 2010,
columns = NULL,
Expand Down
Loading

0 comments on commit a735364

Please sign in to comment.