From 34ba218ae8be0a4746e9e81512105b63f83d3bc0 Mon Sep 17 00:00:00 2001 From: Mauro Lopreten Date: Mon, 22 Apr 2024 19:22:41 -0300 Subject: [PATCH 1/6] Change DESCRIPTION name: metaSurvey to metasurvey --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0d1b532..9b0dba9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,4 +1,4 @@ -Package: metaSurvey +Package: metasurvey Title: Survey processing with metaprogramming Version: 0.0.1 Authors@R: From e094c9c96cccbac164a958c25f5f35aeef794bcb Mon Sep 17 00:00:00 2001 From: Mauro Lopreten Date: Mon, 22 Apr 2024 19:23:13 -0300 Subject: [PATCH 2/6] Modify load_survey.R enviroment variables use name metaSurvey --- R/load_survey.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/load_survey.R b/R/load_survey.R index 978a8b7..f7e7df4 100644 --- a/R/load_survey.R +++ b/R/load_survey.R @@ -39,10 +39,10 @@ load_survey <- function( ) } - .engine <- Sys.getenv("metaSurvey.engine") + .engine <- Sys.getenv("metasurvey.engine") .namespace <- ls( - envir = asNamespace("metaSurvey"), + envir = asNamespace("metasurvey"), pattern = "load_survey" ) From d8cbaba1bb32f7837f02ad6ff2c70044b680c780 Mon Sep 17 00:00:00 2001 From: Mauro Lopreten Date: Mon, 22 Apr 2024 19:23:46 -0300 Subject: [PATCH 3/6] metaSurvey to metasurvey change name and enviroment variables --- R/set_engine.R | 8 ++++---- R/utils.R | 4 ++-- tests/testthat/test-load_survey_example.R | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/set_engine.R b/R/set_engine.R index eaafdcc..89eaf82 100644 --- a/R/set_engine.R +++ b/R/set_engine.R @@ -20,7 +20,7 @@ set_engine <- function(.engine = show_engines()) { .engine %in% .support_engine ) { Sys.setenv( - "metaSurvey.engine" = .engine + "metasurvey.engine" = .engine ) } else { stop( @@ -37,7 +37,7 @@ set_engine <- function(.engine = show_engines()) { message( glue_col( "{green Engine: {.engine}}", - .engine = Sys.getenv("metaSurvey.engine") + .engine = Sys.getenv("metasurvey.engine") ) ) @@ -73,7 +73,7 @@ show_engines <- function() { #' @keywords engine get_engine <- function() { - Sys.getenv("metaSurvey.engine") + Sys.getenv("metasurvey.engine") } #' @title default_engine @@ -86,6 +86,6 @@ default_engine <- function(.engine = "data.table") { engine_env <- get_engine() Sys.setenv( - "metaSurvey.engine" = engine_env %@% .engine + "metasurvey.engine" = engine_env %@% .engine ) } diff --git a/R/utils.R b/R/utils.R index 690d4f1..c558a03 100644 --- a/R/utils.R +++ b/R/utils.R @@ -37,9 +37,9 @@ validate_weight <- function(svy, weight) { load_survey_example <- function(path = NULL) { if (is.null(path)) { - dir(system.file("extdata", package = "metaSurvey")) + dir(system.file("extdata", package = "metasurvey")) } else { - system.file("extdata", path, package = "metaSurvey", mustWork = TRUE) + system.file("extdata", path, package = "metasurvey", mustWork = TRUE) } } diff --git a/tests/testthat/test-load_survey_example.R b/tests/testthat/test-load_survey_example.R index a55de66..fd1069f 100644 --- a/tests/testthat/test-load_survey_example.R +++ b/tests/testthat/test-load_survey_example.R @@ -9,7 +9,7 @@ test_that("load_survey_example works correctly", { # Test that the function returns the correct file when a path is provided testthat::expect_equal( load_survey_example("2019-2021.csv"), - system.file("extdata", "2019-2021.csv", package = "metaSurvey", mustWork = TRUE) + system.file("extdata", "2019-2021.csv", package = "metasurvey", mustWork = TRUE) ) # Test that the function throws an error when a non-existent path is provided From aebc9508a4f2b7d3d6f29b38f314aba4c1a97b85 Mon Sep 17 00:00:00 2001 From: Mauro Lopreten Date: Mon, 22 Apr 2024 19:25:24 -0300 Subject: [PATCH 4/6] Ejemplo --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b942ee0..ed21a7c 100644 --- a/README.md +++ b/README.md @@ -46,22 +46,22 @@ eph2022_3 <- load_survey( svy_edition = "2022_3", svy_weight = "PONDERA" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pea", ESTADO %in% 1:2 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pet", ESTADO != 4 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "po", ESTADO == 1 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pd", ESTADO == 2 ~ 1, .default = 0 From 507f72e480154e8d5a8b475d45223db2d1b37371 Mon Sep 17 00:00:00 2001 From: Mauro Lopreten Date: Mon, 22 Apr 2024 19:33:02 -0300 Subject: [PATCH 5/6] Fix build vigentte --- doc/use_recipes.R | 24 +++++++++--------- doc/use_recipes.Rmd | 52 ++++++++++++++++++++------------------- doc/use_recipes.html | 27 +++++++++++--------- man/metaSurvey-package.Rd | 26 -------------------- vignettes/use_recipes.Rmd | 26 +++++++++++--------- 5 files changed, 68 insertions(+), 87 deletions(-) delete mode 100644 man/metaSurvey-package.Rd diff --git a/doc/use_recipes.R b/doc/use_recipes.R index 8d24d5d..500caa4 100644 --- a/doc/use_recipes.R +++ b/doc/use_recipes.R @@ -5,7 +5,7 @@ knitr::opts_chunk$set( ) ## ----setup-------------------------------------------------------------------- -library(metaSurvey) +library(metasurvey) set_engine( "data.table" @@ -47,7 +47,7 @@ new_svy <- svy_example %>% Division == "C2" ~ "Servicios", Division == "E1" ~ "Servicios" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "tipo_actividad", B1_1_1 == 1 ~ "I + D Interna", B1_2_1 == 1 ~ "I + D Externa", @@ -60,30 +60,30 @@ new_svy <- svy_example %>% B1_9_1 == 1 ~ "Gestión", .default = "Otra" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "tipo_innovacion", E1_1_1 == 1 ~ "Producto", E1_2_1 == 1 ~ "Proceso", .default = "Otra" ) %>% - metaSurvey::step_compute( + metasurvey::step_compute( subsector = Division ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "cant_traba_tramo", data.table::between(IG_4_1_3, 0, 4) ~ "1", data.table::between(IG_4_1_3, 5, 19) ~ "2", data.table::between(IG_4_1_3, 20, 99) ~ "3", IG_4_1_3 > 99 ~ "4" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "ingreso_vta_pesos", data.table::between(IG_5_1_1_3, 0, 9942787) ~ "1", data.table::between(IG_5_1_1_3, 9942788, 49713934) ~ "2", # nolint data.table::between(IG_5_1_1_3, 49713935, 372854507) ~ "3", # nolint IG_5_1_1_3 > 372854507 ~ "4" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "tamanio", cant_traba_tramo == "1" & ingreso_vta_pesos == "1" ~ "Pequenias", cant_traba_tramo == "2" & ingreso_vta_pesos == "2" ~ "Pequenias", @@ -102,7 +102,7 @@ new_svy <- svy_example %>% cant_traba_tramo == "2" & ingreso_vta_pesos == "4" ~ "Grandes", cant_traba_tramo == "3" & ingreso_vta_pesos == "4" ~ "Grandes" ) %>% - metaSurvey::step_compute( + metasurvey::step_compute( subsector = Division ) @@ -119,22 +119,22 @@ eph2022_3 <- load_survey( svy_edition = "2022_3", svy_weight = "PONDERA" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pea", ESTADO %in% 1:2 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pet", ESTADO != 4 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "po", ESTADO == 1 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pd", ESTADO == 2 ~ 1, .default = 0 diff --git a/doc/use_recipes.Rmd b/doc/use_recipes.Rmd index b810904..402c3b2 100644 --- a/doc/use_recipes.Rmd +++ b/doc/use_recipes.Rmd @@ -13,9 +13,11 @@ knitr::opts_chunk$set( comment = "#>" ) ``` + +# Caso de Uso ```{r setup} -library(metaSurvey) +library(metasurvey) set_engine( "data.table" @@ -35,7 +37,7 @@ svy_example <- load_survey( set_use_copy(TRUE) -new_svy <- svy_example |> +new_svy <- svy_example %>% step_recode( new_var = "realiza_innovacion", B1_1_1 == 1 ~ "Realiza innovación", @@ -48,7 +50,7 @@ new_svy <- svy_example |> B1_8_1 == 1 ~ "Realiza innovación", B1_9_1 == 1 ~ "Realiza innovación", .default = "No realiza innovación" - ) |> + ) %>% step_recode( new_var = "sector", data.table::between(Division, 10, 33) ~ "Industria", @@ -56,8 +58,8 @@ new_svy <- svy_example |> Division == "C1" ~ "Industria", Division == "C2" ~ "Servicios", Division == "E1" ~ "Servicios" - ) |> - metaSurvey::step_recode( + ) %>% + metasurvey::step_recode( new_var = "tipo_actividad", B1_1_1 == 1 ~ "I + D Interna", B1_2_1 == 1 ~ "I + D Externa", @@ -69,31 +71,31 @@ new_svy <- svy_example |> B1_8_1 == 1 ~ "Marketing", B1_9_1 == 1 ~ "Gestión", .default = "Otra" - ) |> - metaSurvey::step_recode( + ) %>% + metasurvey::step_recode( new_var = "tipo_innovacion", E1_1_1 == 1 ~ "Producto", E1_2_1 == 1 ~ "Proceso", .default = "Otra" - ) |> - metaSurvey::step_compute( + ) %>% + metasurvey::step_compute( subsector = Division - ) |> - metaSurvey::step_recode( + ) %>% + metasurvey::step_recode( new_var = "cant_traba_tramo", data.table::between(IG_4_1_3, 0, 4) ~ "1", data.table::between(IG_4_1_3, 5, 19) ~ "2", data.table::between(IG_4_1_3, 20, 99) ~ "3", IG_4_1_3 > 99 ~ "4" - ) |> - metaSurvey::step_recode( + ) %>% + metasurvey::step_recode( new_var = "ingreso_vta_pesos", data.table::between(IG_5_1_1_3, 0, 9942787) ~ "1", data.table::between(IG_5_1_1_3, 9942788, 49713934) ~ "2", # nolint data.table::between(IG_5_1_1_3, 49713935, 372854507) ~ "3", # nolint IG_5_1_1_3 > 372854507 ~ "4" - ) |> - metaSurvey::step_recode( + ) %>% + metasurvey::step_recode( new_var = "tamanio", cant_traba_tramo == "1" & ingreso_vta_pesos == "1" ~ "Pequenias", cant_traba_tramo == "2" & ingreso_vta_pesos == "2" ~ "Pequenias", @@ -111,8 +113,8 @@ new_svy <- svy_example |> cant_traba_tramo == "1" & ingreso_vta_pesos == "4" ~ "Grandes", cant_traba_tramo == "2" & ingreso_vta_pesos == "4" ~ "Grandes", cant_traba_tramo == "3" & ingreso_vta_pesos == "4" ~ "Grandes" - ) |> - metaSurvey::step_compute( + ) %>% + metasurvey::step_compute( subsector = Division ) @@ -130,23 +132,23 @@ eph2022_3 <- load_survey( svy_type = "eph", svy_edition = "2022_3", svy_weight = "PONDERA" -) |> - metaSurvey::step_recode( +) %>% + metasurvey::step_recode( "pea", ESTADO %in% 1:2 ~ 1, .default = 0 - ) |> - metaSurvey::step_recode( + ) %>% + metasurvey::step_recode( "pet", ESTADO != 4 ~ 1, .default = 0 - ) |> - metaSurvey::step_recode( + ) %>% + metasurvey::step_recode( "po", ESTADO == 1 ~ 1, .default = 0 - ) |> - metaSurvey::step_recode( + ) %>% + metasurvey::step_recode( "pd", ESTADO == 2 ~ 1, .default = 0 diff --git a/doc/use_recipes.html b/doc/use_recipes.html index d80c5ec..7669f4c 100644 --- a/doc/use_recipes.html +++ b/doc/use_recipes.html @@ -340,7 +340,9 @@

use_recipes

-
library(metaSurvey)
+
+

Caso de Uso

+
library(metasurvey)
 
 set_engine(
   "data.table"
@@ -383,7 +385,7 @@ 

use_recipes

Division == "C2" ~ "Servicios", Division == "E1" ~ "Servicios" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "tipo_actividad", B1_1_1 == 1 ~ "I + D Interna", B1_2_1 == 1 ~ "I + D Externa", @@ -396,30 +398,30 @@

use_recipes

B1_9_1 == 1 ~ "Gestión", .default = "Otra" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "tipo_innovacion", E1_1_1 == 1 ~ "Producto", E1_2_1 == 1 ~ "Proceso", .default = "Otra" ) %>% - metaSurvey::step_compute( + metasurvey::step_compute( subsector = Division ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "cant_traba_tramo", data.table::between(IG_4_1_3, 0, 4) ~ "1", data.table::between(IG_4_1_3, 5, 19) ~ "2", data.table::between(IG_4_1_3, 20, 99) ~ "3", IG_4_1_3 > 99 ~ "4" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "ingreso_vta_pesos", data.table::between(IG_5_1_1_3, 0, 9942787) ~ "1", data.table::between(IG_5_1_1_3, 9942788, 49713934) ~ "2", # nolint data.table::between(IG_5_1_1_3, 49713935, 372854507) ~ "3", # nolint IG_5_1_1_3 > 372854507 ~ "4" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "tamanio", cant_traba_tramo == "1" & ingreso_vta_pesos == "1" ~ "Pequenias", cant_traba_tramo == "2" & ingreso_vta_pesos == "2" ~ "Pequenias", @@ -438,7 +440,7 @@

use_recipes

cant_traba_tramo == "2" & ingreso_vta_pesos == "4" ~ "Grandes", cant_traba_tramo == "3" & ingreso_vta_pesos == "4" ~ "Grandes" ) %>% - metaSurvey::step_compute( + metasurvey::step_compute( subsector = Division ) #> No news variable created: listDivision @@ -467,26 +469,27 @@

use_recipes

svy_edition = "2022_3", svy_weight = "PONDERA" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pea", ESTADO %in% 1:2 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pet", ESTADO != 4 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "po", ESTADO == 1 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pd", ESTADO == 2 ~ 1, .default = 0 )
+

Introduction

diff --git a/man/metaSurvey-package.Rd b/man/metaSurvey-package.Rd deleted file mode 100644 index 9eabe8e..0000000 --- a/man/metaSurvey-package.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/metaSurvey-package.R -\docType{package} -\name{metaSurvey-package} -\alias{metaSurvey} -\alias{metaSurvey-package} -\title{metaSurvey: Survey processing with metaprogramming} -\description{ -This package provides a set of functions to process survey data using metaprogramming. It is designed to work with the survey package, but it can be used with any other package that provides a similar data structure. The main goal of this package is to provide a set of functions that can be used to process survey data in a more efficient way, by using metaprogramming to generate code that can be used to process the data. -} -\author{ -\strong{Maintainer}: Mauro Loprete \email{mloprete@cognus.cl} - -Authors: -\itemize{ - \item Natalia da Silva -} - -Other contributors: -\itemize{ - \item COGNUS [funder] - \item ANII [copyright holder] -} - -} -\keyword{internal} diff --git a/vignettes/use_recipes.Rmd b/vignettes/use_recipes.Rmd index 36a978f..402c3b2 100644 --- a/vignettes/use_recipes.Rmd +++ b/vignettes/use_recipes.Rmd @@ -13,9 +13,11 @@ knitr::opts_chunk$set( comment = "#>" ) ``` + +# Caso de Uso ```{r setup} -library(metaSurvey) +library(metasurvey) set_engine( "data.table" @@ -57,7 +59,7 @@ new_svy <- svy_example %>% Division == "C2" ~ "Servicios", Division == "E1" ~ "Servicios" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "tipo_actividad", B1_1_1 == 1 ~ "I + D Interna", B1_2_1 == 1 ~ "I + D Externa", @@ -70,30 +72,30 @@ new_svy <- svy_example %>% B1_9_1 == 1 ~ "Gestión", .default = "Otra" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "tipo_innovacion", E1_1_1 == 1 ~ "Producto", E1_2_1 == 1 ~ "Proceso", .default = "Otra" ) %>% - metaSurvey::step_compute( + metasurvey::step_compute( subsector = Division ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "cant_traba_tramo", data.table::between(IG_4_1_3, 0, 4) ~ "1", data.table::between(IG_4_1_3, 5, 19) ~ "2", data.table::between(IG_4_1_3, 20, 99) ~ "3", IG_4_1_3 > 99 ~ "4" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "ingreso_vta_pesos", data.table::between(IG_5_1_1_3, 0, 9942787) ~ "1", data.table::between(IG_5_1_1_3, 9942788, 49713934) ~ "2", # nolint data.table::between(IG_5_1_1_3, 49713935, 372854507) ~ "3", # nolint IG_5_1_1_3 > 372854507 ~ "4" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( new_var = "tamanio", cant_traba_tramo == "1" & ingreso_vta_pesos == "1" ~ "Pequenias", cant_traba_tramo == "2" & ingreso_vta_pesos == "2" ~ "Pequenias", @@ -112,7 +114,7 @@ new_svy <- svy_example %>% cant_traba_tramo == "2" & ingreso_vta_pesos == "4" ~ "Grandes", cant_traba_tramo == "3" & ingreso_vta_pesos == "4" ~ "Grandes" ) %>% - metaSurvey::step_compute( + metasurvey::step_compute( subsector = Division ) @@ -131,22 +133,22 @@ eph2022_3 <- load_survey( svy_edition = "2022_3", svy_weight = "PONDERA" ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pea", ESTADO %in% 1:2 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pet", ESTADO != 4 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "po", ESTADO == 1 ~ 1, .default = 0 ) %>% - metaSurvey::step_recode( + metasurvey::step_recode( "pd", ESTADO == 2 ~ 1, .default = 0 From aa1bb96f1516d66510ad930742075a6164fca606 Mon Sep 17 00:00:00 2001 From: Mauro Lopreten Date: Mon, 22 Apr 2024 19:35:36 -0300 Subject: [PATCH 6/6] Upate workflow --- .github/workflows/R-CMD-check.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 74d8c97..9427319 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -2,9 +2,9 @@ # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: [main, master] + branches: [main, master,develop] pull_request: - branches: [main, master] + branches: [main, master,develop] name: R-CMD-check