Skip to content

Commit cb3f2de

Browse files
committed
updates to examples
1 parent f796cef commit cb3f2de

File tree

8 files changed

+54
-54
lines changed

8 files changed

+54
-54
lines changed

R/combine_estimates.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#' \insertRef{BDA3}{verdata}
2727
#'
2828
#' @examples
29-
#' \dontrun{
29+
#' \donttest{
3030
#' set.seed(19481210)
3131
#'
3232
#' library(dplyr)

R/filter_standard_cev.R

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,61 +18,61 @@
1818
#' @importFrom dplyr %>%
1919
#'
2020
#' @examples
21-
#' \dontrun{
21+
#' \donttest{
2222
#' local_dir <- system.file("extdata", "right", package = "verdata")
23-
#' replicates_data <- read_replicates(local_dir, "reclutamiento", 1, 2)
23+
#' replicates_data <- read_replicates(local_dir, "reclutamiento", c(1, 2), version = "v1")
2424
#' filter_standard_cev(replicates_data, "reclutamiento", perp_change = TRUE)
2525
#' }
2626
filter_standard_cev <- function(replicates_data, violation, perp_change = TRUE) {
2727

28-
if (!is.data.frame(replicates_data)) {
29-
stop("The argument 'replicates_data' must be a data frame")
30-
}
28+
if (!is.data.frame(replicates_data)) {
29+
stop("The argument 'replicates_data' must be a data frame")
30+
}
3131

3232
if (!(violation %in% c("homicidio", "secuestro", "reclutamiento", "desaparicion"))) {
3333

34-
stop("Violation argument incorrectly specified. Please put any of the following
34+
stop("Violation argument incorrectly specified. Please put any of the following
3535
violations (in quotes and in lower case): homicidio, secuestro,
3636
reclutamiento or desaparicion")
3737

3838
}
3939

4040
data_filter <- replicates_data %>%
4141
dplyr::mutate(edad_minors = dplyr::case_when(edad_jep == "INFANCIA" ~ "MENOR",
42-
edad_jep == "ADOLESCENCIA" ~ "MENOR",
43-
edad_jep == "ADULTEZ" ~ "ADULTO",
42+
edad_jep == "ADOLESCENCIA" ~ "MENOR",
43+
edad_jep == "ADULTEZ" ~ "ADULTO",
44+
TRUE ~ NA_character_)) %>%
45+
dplyr::mutate(edad_minors_imputed = dplyr::if_else(edad_jep_imputed == FALSE, FALSE, TRUE)) %>%
46+
dplyr::mutate(etnia2 = dplyr::case_when(etnia %in% c('MESTIZO') ~ "MESTIZO",
47+
etnia %in% c('INDIGENA','NARP','ROM') ~ "ETNICO",
4448
TRUE ~ NA_character_)) %>%
45-
dplyr::mutate(edad_minors_imputed = dplyr::if_else(edad_jep_imputed == FALSE, FALSE, TRUE)) %>%
46-
dplyr::mutate(etnia2 = dplyr::case_when(etnia %in% c('MESTIZO') ~ "MESTIZO",
47-
etnia %in% c('INDIGENA','NARP','ROM') ~ "ETNICO",
48-
TRUE ~ NA_character_)) %>%
49-
dplyr::mutate(etnia2 = as.character(etnia2)) %>%
50-
dplyr::mutate(etnia2_imputed = dplyr::if_else(etnia_imputed == FALSE, FALSE, TRUE)) %>%
51-
dplyr::mutate(quinquenio = dplyr::case_when(yy_hecho >= 1985 & yy_hecho <= 1989 ~ "1985_1989",
52-
yy_hecho >= 1990 & yy_hecho <= 1994 ~ "1990_1994",
53-
yy_hecho >= 1995 & yy_hecho <= 1999 ~ "1995_1999",
54-
yy_hecho >= 2000 & yy_hecho <= 2004 ~ "2000_2004",
55-
yy_hecho >= 2005 & yy_hecho <= 2009 ~ "2005_2009",
56-
yy_hecho >= 2010 & yy_hecho <= 2014 ~ "2010_2014",
57-
yy_hecho >= 2015 & yy_hecho <= 2019 ~ "2015_2019",
58-
TRUE ~ NA_character_)) %>%
59-
dplyr::mutate(muni_code_hecho = as.character(muni_code_hecho)) %>%
60-
dplyr::mutate(dplyr::across(muni_code_hecho,
61-
~ dplyr::case_when(. == "91236" ~ "91263",
62-
TRUE ~ .))) %>%
63-
dplyr::mutate(muni_code_hecho = as.numeric(muni_code_hecho)) %>%
64-
assertr::verify(!is.na(quinquenio))
49+
dplyr::mutate(etnia2 = as.character(etnia2)) %>%
50+
dplyr::mutate(etnia2_imputed = dplyr::if_else(etnia_imputed == FALSE, FALSE, TRUE)) %>%
51+
dplyr::mutate(quinquenio = dplyr::case_when(yy_hecho >= 1985 & yy_hecho <= 1989 ~ "1985_1989",
52+
yy_hecho >= 1990 & yy_hecho <= 1994 ~ "1990_1994",
53+
yy_hecho >= 1995 & yy_hecho <= 1999 ~ "1995_1999",
54+
yy_hecho >= 2000 & yy_hecho <= 2004 ~ "2000_2004",
55+
yy_hecho >= 2005 & yy_hecho <= 2009 ~ "2005_2009",
56+
yy_hecho >= 2010 & yy_hecho <= 2014 ~ "2010_2014",
57+
yy_hecho >= 2015 & yy_hecho <= 2019 ~ "2015_2019",
58+
TRUE ~ NA_character_)) %>%
59+
dplyr::mutate(muni_code_hecho = as.character(muni_code_hecho)) %>%
60+
dplyr::mutate(dplyr::across(muni_code_hecho,
61+
~ dplyr::case_when(. == "91236" ~ "91263",
62+
TRUE ~ .))) %>%
63+
dplyr::mutate(muni_code_hecho = as.numeric(muni_code_hecho)) %>%
64+
assertr::verify(!is.na(quinquenio))
6565

6666
if (perp_change == TRUE) {
6767

68-
data_filter <- data_filter %>%
69-
dplyr::mutate(p_str = as.character(p_str)) %>%
70-
dplyr::mutate(p_str = base::ifelse(yy_hecho > 2016 & p_str == "GUE-FARC",
71-
"GUE-OTRO", p_str))
68+
data_filter <- data_filter %>%
69+
dplyr::mutate(p_str = as.character(p_str)) %>%
70+
dplyr::mutate(p_str = base::ifelse(yy_hecho > 2016 & p_str == "GUE-FARC",
71+
"GUE-OTRO", p_str))
7272

7373
} else {
7474

75-
logger::log_info("Not change in perp's argument")
75+
logger::log_info("Not change in perp's argument")
7676

7777
}
7878

@@ -111,19 +111,19 @@ filter_standard_cev <- function(replicates_data, violation, perp_change = TRUE)
111111
is_forced_dis == 1 & is_conflict == 1 ~ 1))
112112

113113
} else if (violation == "reclutamiento") {
114-
# apply additional filters for reclutamiento
115-
data_filter <- data_filter %>%
116-
dplyr::mutate(periodo_pres = dplyr::case_when(yy_hecho >= 1990 & yy_hecho <= 1993 ~ "1990_1993",
117-
yy_hecho >= 1994 & yy_hecho <= 1997 ~ "1994_1997",
118-
yy_hecho >= 1998 & yy_hecho <= 2001 ~ "1998_2001",
119-
yy_hecho >= 2002 & yy_hecho <= 2005 ~ "2002_2005",
120-
yy_hecho >= 2006 & yy_hecho <= 2009 ~ "2006_2009",
121-
yy_hecho >= 2010 & yy_hecho <= 2013 ~ "2010_2013",
122-
yy_hecho >= 2014 & yy_hecho <= 2017 ~ "2014_2017",
123-
TRUE ~ NA_character_)) %>%
124-
assertr::verify(!is.na(periodo_pres)) %>%
125-
dplyr::filter(edad_jep == "INFANCIA" |
126-
edad_jep == "ADOLESCENCIA")
114+
# apply additional filters for reclutamiento
115+
data_filter <- data_filter %>%
116+
dplyr::mutate(periodo_pres = dplyr::case_when(yy_hecho >= 1990 & yy_hecho <= 1993 ~ "1990_1993",
117+
yy_hecho >= 1994 & yy_hecho <= 1997 ~ "1994_1997",
118+
yy_hecho >= 1998 & yy_hecho <= 2001 ~ "1998_2001",
119+
yy_hecho >= 2002 & yy_hecho <= 2005 ~ "2002_2005",
120+
yy_hecho >= 2006 & yy_hecho <= 2009 ~ "2006_2009",
121+
yy_hecho >= 2010 & yy_hecho <= 2013 ~ "2010_2013",
122+
yy_hecho >= 2014 & yy_hecho <= 2017 ~ "2014_2017",
123+
TRUE ~ NA_character_)) %>%
124+
assertr::verify(!is.na(periodo_pres)) %>%
125+
dplyr::filter(edad_jep == "INFANCIA" |
126+
edad_jep == "ADOLESCENCIA")
127127
}
128128

129129
return(data_filter)

R/summary_observed.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#' `summary_observed`.
1717
#' @export
1818
#' @examples
19-
#' \dontrun{
19+
#' \donttest{
2020
#' local_dir <- system.file("extdata", "right", package = "verdata")
2121
#' replicates_data <- read_replicates(local_dir, "reclutamiento", c(1, 2), version = "v1")
2222
#' tab_observed <- summary_observed("reclutamiento", replicates_data,

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Para el uso de este paquete es necesario haber descargado previamente los datos
8181

8282
### Datos imputados:
8383

84-
* La función `combine_replicates` usa la aproximación normal usando las reglas de total expectativa y varianza para combinar las réplicas, lo que permite obtener un intervalo de la imputación. Ver sección 18.2 de [*Bayesian Data Analysis*](https://www.stat.columbia.edu/~gelman/book/) para más información.
84+
* La función `combine_replicates` usa la aproximación normal usando las reglas de total expectativa y varianza para combinar las réplicas, lo que permite obtener un intervalo de la imputación. Ver sección 18.2 de [*Bayesian Data Analysis*](https://sites.stat.columbia.edu/gelman/book/) para más información.
8585

8686
### Datos estimados:
8787

inst/docs/README-en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ To use this package, it is necessary to have previously downloaded the data from
8282

8383
### Imputed data
8484

85-
* The `combine_replicates` function uses the Normal approximation using the laws of total expectation and variance to combine the replicates, yielding a 95% confidence interval and a point estimate of the mean number of documented victims taking the imputation uncertainty into consideration. See Section 18.2 of [*Bayesian Data Analysis*](http://www.stat.columbia.edu/~gelman/book/) for more information.
85+
* The `combine_replicates` function uses the Normal approximation using the laws of total expectation and variance to combine the replicates, yielding a 95% confidence interval and a point estimate of the mean number of documented victims taking the imputation uncertainty into consideration. See Section 18.2 of [*Bayesian Data Analysis*](https://sites.stat.columbia.edu/gelman/book/) for more information.
8686

8787
### Estimates
8888

man/combine_estimates.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/filter_standard_cev.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/proportions_observed.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)