Skip to content

Commit

Permalink
Merge pull request #32 from HRDAG/add-new-functions
Browse files Browse the repository at this point in the history
Add data objects for data dictionary; closes #18
  • Loading branch information
thegargiulian authored Oct 23, 2023
2 parents b5ae3b8 + c0e74c1 commit 538d18b
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 11 deletions.
25 changes: 25 additions & 0 deletions R/diccionario_replicas.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ============================================
# Authors: MG
# Maintainers: MG
# Copyright: 2023, HRDAG, GPL v2 or later
# ============================================

#' Diccionario de datos para las variables que aparecen en los archivos de las
#' réplicas.
#'
#' @docType data
#'
#' @usage data(diccionario_replicas)
#' @format Un data frame con 55 filas y 4 variables.
#' \describe{
#' \item{nombre_variable}{nombre de la variable}
#' \item{tipo}{tipo de la variable: caracter, numérico, lógico}
#' \item{detalle_variable}{explicación detallada de la variable}
#' \item{categorias_variable}{valores posibles de la variable}
#' }
#'
#' @source Proyecto conjunto JEP-CEV-HRDAG.
#'
"diccionario_replicas"

# done.
24 changes: 24 additions & 0 deletions R/diccionario_vars_adicional.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ============================================
# Authors: MG
# Maintainers: MG
# Copyright: 2023, HRDAG, GPL v2 or later
# ============================================

#' Variables adicionales que pueden ser útiles para analizar los datos.
#'
#' @docType data
#'
#' @usage data(diccionario_vars_adicional)
#' @format Un data frame con 11 filas y 4 variables.
#' \describe{
#' \item{nombre_variable}{nombre de la variable}
#' \item{tipo}{tipo de la variable: caracter, numérico, lógico}
#' \item{detalle_variable}{explicación detallada de la variable}
#' \item{categorias_variable}{valores posibles de la variable}
#' }
#'
#' @source Proyecto conjunto JEP-CEV-HRDAG.
#'
"diccionario_vars_adicional"

# done.
4 changes: 2 additions & 2 deletions R/estratificacion.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
#' @docType data
#'
#' @usage data(estratificacion)
#' @format Un data frame con 31 filas y 4 variables
#' @format Un data frame con 31 filas y 4 variables.
#' \describe{
#' \item{violacion}{el hecho de violencia al analizar}
#' \item{estimacion}{el tipo de análisis que utiliza la estratificación (p.ej., patrones de violencia por año, sexo, etc.)}
#' \item{estratificacion}{las variables utilizadas para estratificar las estimaciones}
#' \item{notas}{notas adicionales sobre la estratificación; NA si no hay notas}
#' }
#'
#' @source proyecto conjunto JEP-CEV-HRDAG
#' @source Proyecto conjunto JEP-CEV-HRDAG.
#'
"estratificacion"

Expand Down
4 changes: 2 additions & 2 deletions R/stratification.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
#' @docType data
#'
#' @usage data(stratification)
#' @format A data frame with 31 rows and 4 variables
#' @format A data frame with 31 rows and 4 variables.
#' \describe{
#' \item{violation}{the human rights violation being analyzed}
#' \item{estimation}{the type of analysis the stratification was used for (e.g., patterns of violence by year, sex, etc.)}
#' \item{stratification}{the variables used to stratify the estimates}
#' \item{notes}{additional notes about the stratification; NA if no notes}
#' }
#'
#' @source joint JEP-CEV-HRDAG project
#' @source Joint JEP-CEV-HRDAG project.
#'
"stratification"

Expand Down
Binary file added data/diccionario_replicas.rda
Binary file not shown.
Binary file added data/diccionario_vars_adicional.rda
Binary file not shown.
Binary file modified inst/docs/diccionario-variables-replicas.xlsx
Binary file not shown.
27 changes: 27 additions & 0 deletions man/diccionario_replicas.Rd

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

25 changes: 25 additions & 0 deletions man/diccionario_vars_adicional.Rd

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

4 changes: 2 additions & 2 deletions man/estratificacion.Rd

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

4 changes: 2 additions & 2 deletions man/stratification.Rd

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

3 changes: 0 additions & 3 deletions tests/testthat/test-estimate_mse.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,12 @@ testthat::test_that("mse function returns correct results when using lookup func

# there are warnings here because our toy estimates directory does not contain
# the same number of files as the real estimates directory would
s4_start <- Sys.time()
r4 <- mse(stratum_data = stratum_4,
stratum_name = "stratum 4",
estimates_dir = estimates_dir)
s4_end <- Sys.time()

testthat::expect_equal(nrow(r4), 1000)
testthat::expect_named(r4, c("validated", "N", "valid_sources", "n_obs", "stratum_name"))
testthat::expect_true(as.numeric(s4_end - s4_start) > 5) # needs to estimate, should take more time

})

Expand Down

0 comments on commit 538d18b

Please sign in to comment.