Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change name metaSurvey to metasurvey #13

Merged
merged 6 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Package: metaSurvey
Package: metasurvey
Title: Survey processing with metaprogramming
Version: 0.0.1
Authors@R:
Expand Down
4 changes: 2 additions & 2 deletions R/load_survey.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
8 changes: 4 additions & 4 deletions R/set_engine.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set_engine <- function(.engine = show_engines()) {
.engine %in% .support_engine
) {
Sys.setenv(
"metaSurvey.engine" = .engine
"metasurvey.engine" = .engine
)
} else {
stop(
Expand All @@ -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")
)
)

Expand Down Expand Up @@ -73,7 +73,7 @@ show_engines <- function() {
#' @keywords engine

get_engine <- function() {
Sys.getenv("metaSurvey.engine")
Sys.getenv("metasurvey.engine")
}

#' @title default_engine
Expand All @@ -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
)
}
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions doc/use_recipes.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ knitr::opts_chunk$set(
)

## ----setup--------------------------------------------------------------------
library(metaSurvey)
library(metasurvey)

set_engine(
"data.table"
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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
)

Expand All @@ -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
Expand Down
52 changes: 27 additions & 25 deletions doc/use_recipes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ knitr::opts_chunk$set(
comment = "#>"
)
```

# Caso de Uso

```{r setup}
library(metaSurvey)
library(metasurvey)

set_engine(
"data.table"
Expand All @@ -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",
Expand All @@ -48,16 +50,16 @@ 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",
data.table::between(Division, 34, 99) ~ "Servicios",
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",
Expand All @@ -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",
Expand All @@ -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
)

Expand All @@ -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
Expand Down
Loading