#===============================================================================
# Diccionario ENE (en orden alfabético)
#===============================================================================
# add_ene_cise_ <- function(df, year, month, ...) {
# # Identifica inputs y outputs
# output <- "cise_"
# inputs <- "categoria_ocupacion"
#
# # Genera la nueva variable
# df[[output]] <- df[[inputs]] %>%
# cut(breaks = c(0, 1, 2, 6, 7), labels = FALSE)
#
# # Etiqueta los valores
# attr(df[[output]], "labels") <-
# c("Empleador" = 1,
# "Cuenta propia" = 2,
# "Asalariado" = 3,
# "FNR" = 4,
# "ns/nr" = NA)
#
# # Etiqueta la variable
# attr(df[[output]], "label") <- "Categoría de ocupación"
#
# # Reporta el resultado
# return(df)
# }
#
# add_ene_duremp_ <- function(df, year, month, ...) {
# # Identifica inputs y outputs
# output <- c("duremp_")
# inputs <- c("b17_ano", "b17_mes")
#
# # Particiona los inputs
# ano <- inputs[1]
# mes <- inputs[2]
#
# # Genera la nueva variable
# temp <- (year - df[[ano]]) + (month - df[[mes]]) / 12
# touse <- (df[[mes]] %in% 999 | df[[ano]] %in% 9999)
# temp[touse] <- NA_real_
# df[[output]] <- temp
#
# # # Etiqueta la variable
# attr(df[[output]], "label") <- "Duración del empleo (en años)"
#
# # Reporta el resultado
# return(df)
# }
#
# add_ene_duremp_tr_ <- function(df, year, month, ...) {
# # Identifica inputs y outputs
# output <- c("duremp_tr_")
# inputs <- c("b17_ano", "b17_mes")
#
# # Genera los inputs intermedios (si es que no existen ya)
# if (!("duremp_" %in% colnames(df))) {
# df <- add_ene_duremp_(df, year, month)
# }
#
# # Genera la nueva variable
# df[[output]] <- df[["duremp_"]] %>%
# cut(breaks = c(-Inf, 1, 5, 10, Inf), labels = FALSE)
#
# # Etiqueta los valores
# attr(df[[output]], "labels") <-
# c("[0, 1)" = 1,
# "[1, 5)" = 2,
# "[5, 10)" = 3,
# "[10, ∞)" = 4,
# "ns/nr" = NA)
#
# # Etiqueta la variable
# attr(df[[output]], "label") <- "Tramo de duración de empleo (en años)"
#
# # Reporta el resultado
# return(df)
# }
#
# add_ene_edad_tr_ <- function(df, year, month, ...) {
# # Identifica inputs y outputs
# output <- c("edad_tr_")
# inputs <- c("edad")
#
# # Genera la nueva variable
# df[[output]] <- df[[inputs]] %>%
# cut(breaks = c(-Inf, 14, 24, 34, 44, 54, 64, Inf), labels = FALSE)
#
# # Etiqueta los valores
# attr(df[[output]], "labels") <-
# c("14 o menos" = 1,
# "Entre 15 y 24" = 2,
# "Entre 25 y 34" = 3,
# "Entre 35 y 44" = 4,
# "Entre 45 y 54" = 5,
# "Entre 55 y 64" = 6,
# "65 o mas" = 7,
# "ns/nr" = NA)
#
# # Etiqueta la variable
# attr(df[[output]], "label") <- "Tramo de edad (en años)"
#
# # Reporta el resultado
# return(df)
# }
#
# add_ene_educ_ <- function(df, year, month, ...) {
# # Identifica inputs y outputs
# output <- c("educ_")
# inputs <- c("nivel", "termino_nivel")
#
# # Particiona los inputs
# n <- inputs[1]
# t <- inputs[2]
#
# # Genera la nueva variable
# df[[output]] <-
# dplyr::case_when(df[[n]] %in% 0:2 ~ 1,
# df[[n]] %in% 3 & df[[t]] == 2 ~ 1,
# df[[n]] %in% 3 & df[[t]] == 1 ~ 2,
# df[[n]] %in% c(4:6, 14) & df[[t]] == 2 ~ 2,
# df[[n]] %in% c(4:6, 14) & df[[t]] == 1 ~ 3,
# df[[n]] %in% 7:9 & df[[t]] == 2 ~ 3,
# df[[n]] %in% 7:8 & df[[t]] == 1 ~ 4,
# df[[n]] %in% 9 & df[[t]] == 1 ~ 5,
# df[[n]] %in% 10 ~ 5,
# df[[n]] %in% 11:12 & df[[t]] == 2 ~ 5,
# df[[n]] %in% 11:12 & df[[t]] == 2 ~ 6,
# TRUE ~ NA_real_)
#
# # Etiqueta los valores
# attr(df[[output]], "labels") <-
# c("Básica incompleta o menos" = 1,
# "Básica" = 2,
# "Media" = 3,
# "Técnica" = 4,
# "Profesional" = 5,
# "Postgrado" = 6,
# "ns/nr" = NA)
#
# # Etiqueta la variable
# attr(df[[output]], "label") <- "Nivel educacional"
#
# # Reporta el resultado
# return(df)
# }
#
# add_ene_ocupado_ <- function(df, year, month, ...) {
# # Identifica inputs y outputs
# output <- c("ocupado_")
# inputs <- c("cae_general")
#
# # Genera la nueva variable
# df[[output]] <-
# dplyr::case_when(df[[inputs]] %in% 1:3 ~ 1,
# df[[inputs]] %in% c(0, 4:9) ~ 0,
# TRUE ~ NA_real_)
#
# # Etiqueta los valores
# attr(df[[output]], "labels") <-
# c("No" = 0, "Sí" = 1, "ns/nr" = NA)
#
# # Etiqueta la variable
# attr(df[[output]], "label") <- "Dummy ocupados"
#
# # Reporta el resultado
# return(df)
# }
#
# add_ene_oficio1_ <- function(df, year, month, ...) {
# # Identifica inputs y outputs
# output <- c("oficio1_")
# inputs <- c("b1")
#
# # Genera la nueva variable
# df[[output]] <-
# dplyr::recode(as.numeric(df[[inputs]]), `10` = NA_real_)
#
# # Etiqueta los valores
# attr(df[[output]], "labels") <-
# c("Fuerzas armadas" = 0,
# "Miembros del poder ejecutivo/legislativo y personal directivo" = 1,
# "Profesionales, científicos e intelectuales" = 2,
# "Técnicos profesionales de nivel medio" = 3,
# "Empleados de oficina" = 4,
# "Trabajadores de los servicios y vendedores de comercios y mercados" = 5,
# "Agricultores y trabajadores calificados agropecuarios y pesqueros" = 6,
# "Oficiales, operarios y artesanos de artes mecánicas y otros oficios" = 7,
# "Operadores de instalaciones y maquinas y montadores" = 8,
# "Trabajadores no calificados" = 9,
# "ns/nr" = NA)
#
# # Etiqueta la variable
# attr(df[[output]], "label") <- "Gran grupo de ocupación (CIUO-88)"
#
# # Reporta el resultado
# return(df)
# }
#
# add_ene_rama1_ <- function(df, year, month, ...) {
# # Identifica inputs y outputs
# output <- c("rama1_")
# inputs <- c("b14")
#
# # Genera la nueva variable
# df[[output]] <-
# dplyr::case_when(as.numeric(df[[inputs]]) %in% c(12, 17) ~ 12,
# as.numeric(df[[inputs]]) %in% 13:16 ~ 13,
# TRUE ~ as.numeric(df[[inputs]]))
#
# # Etiqueta los valores
# attr(df[[output]], "labels") <-
# c("Agropecuario-silvícola" = 1,
# "Pesca" = 2,
# "Minería" = 3,
# "Industria manufacturera" = 4,
# "Electricidad, gas y agua" = 5,
# "Construcción" = 6,
# "Comercio" = 7,
# "Hoteles y restaurantes" = 8,
# "Transporte y comunicaciones" = 9,
# "Intermediación financiera" = 10,
# "Actividades inmobiliarias, empresariales y de alquiler" = 11,
# "Servicios personales" = 12,
# "Administración publica" = 13,
# "ns/nr" = NA)
#
# # Etiqueta la variable
# attr(df[[output]], "label") <- "Rama de actividad (CIIU-rev3)"
#
# # Reporta el resultado
# return(df)
# }
#
# add_ene_sexo_ <- function(df, year, month, ...) {
# # Identifica inputs y outputs
# output <- c("sexo_")
# inputs <- c("sexo")
#
# # Genera la nueva variable
# df[[output]] <- df[[inputs]]
#
# # Etiqueta los valores
# attr(df[[output]], "labels") <-
# c("Hombre" = 1, "Mujer" = 2, "ns/nr" = NA)
#
# # Etiqueta la variable
# attr(df[[output]], "label") <- "Sexo"
#
# # Reporta el resultado
# return(df)
# }
#
# add_ene_zona_ <- function(df, year, month, ...) {
# # Identifica inputs y outputs
# output <- c("zona_")
# inputs <- c("tipo")
#
# # Genera la nueva variable
# df[[output]] <-
# as.numeric(df[[inputs]] <= 2)
#
# # Etiqueta los valores
# attr(df[[output]], "labels") <-
# c("Rural" = 0, "Urbano" = 1, "ns/nr" = NA)
#
# # Etiqueta la variable
# attr(df[[output]], "label") <- "Zona"
#
# # Reporta el resultado
# return(df)
# }
#===============================================================================
# Diccionario ESI (en orden alfabético)
#===============================================================================
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.