El trabajo final grupal consiste en la elaboración de un informe en formato RMarkdown donde se trabajará con datos del mercado de trabajo utilizando R. 2. En “texto”: - Explicar brevemente el propósito del informe. - Describir los pasos realizados para encarar las consignas propuestas. También se pueden incorporar comentarios en el código. - Mencionar posibles obstáculos enfrentados durante el proceso y cómo fueron resueltos.

## Cargando paquete requerido: usethis
## 
## Adjuntando el paquete: 'devtools'
## The following objects are masked from 'package:pkgload':
## 
##     has_tests, load_all, package_file
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.0.4     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## 
## Adjuntando el paquete: 'kableExtra'
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     group_rows
  1. Con código: 3.1. Carga de librerías
## Warning in get_microdata(year = 2019:2025, period = 1:4, type = "individual", : No se pudo descargar la base de year 2025, period 4, type individual.
##     Mensaje: Problema con la descarga 2025 period 4. Puede deberse a que la base solicitada no exista.
## 
## 

###ACA ENTRA LA TABLA

# ============================================================
# 5. DEFLACTAR INGRESOS (AJUSTAR POR INFLACIÓN)
# ============================================================
# Unir IPC y deflactar a precios constantes (año base 2025-Q3)
anio_base <- 2025
trimestre_base <- 3

ipc_base <- ipc_trimestral %>%
  filter(ANO4 == anio_base, TRIMESTRE == trimestre_base) %>%
  pull(ipc)



promedio_trimestre <- promedio_trimestre %>%
  left_join(ipc_trimestral, by = c("ANO4", "TRIMESTRE")) %>%  
  mutate(
    ingreso_real = ingreso_promedio * (ipc_base / ipc),  
    ingreso_nominal = ingreso_promedio
  )

# ============================================================
# 6. FILTRAR SOLO PATRONES
# ============================================================
patrones_trimestre <- promedio_trimestre %>%
  filter(CATEGORIA_OCUPACIONAL == "Patron")

# ============================================================
# 7. GRÁFICO CON INGRESO REAL
# ============================================================
ggplot(patrones_trimestre, aes(x = factor(paste(ANO4, TRIMESTRE, sep="-Q")), 
                                y = ingreso_real, 
                                group = Sexo,
                                color = Sexo)) +
  geom_line(size = 1.2) +
  geom_point(size = 2) +
  labs(
    title = "EVOLUCIÓN DEL INGRESO REAL DE PATRONES POR SEXO",
    subtitle = paste("ARGENTINA - TRIMESTRAL 2019 A 2025 (PRECIOS CONSTANTES", anio_base, "-Q", trimestre_base, ")"),
    x = "PERÍODO (AÑO-TRIMESTRE)",
    y = "INGRESO PROMEDIO (PESOS A PRECIOS CONSTANTES)",
    color = "SEXO",
    caption = "FUENTE: EPH - INDEC | AJUSTE POR IPC"
  ) +
  theme_minimal() +
  theme(
    legend.position = "bottom",
    plot.title = element_text(face = "bold", size = 14),
    plot.subtitle = element_text(size = 11, color = "gray40"),
    axis.text.x = element_text(angle = 90, hjust = 1, size = 8)
  ) +
  scale_y_continuous(labels = scales::comma)

# ============================================================
# 8. TABLA DE INGRESOS REALES (FORMATO ANCHO)
# ============================================================
tabla_patrones_real <- patrones_trimestre %>%
  mutate(
    ingreso_formateado = scales::comma(round(ingreso_real, 0))
  ) %>%
  select(periodo, Sexo, ingreso_formateado) %>%
  pivot_wider(names_from = Sexo, values_from = ingreso_formateado) %>%
  arrange(periodo)

# Mostrar tabla con kable
kable(tabla_patrones_real, 
      caption = paste("INGRESO REAL DE PATRONES POR SEXO (PRECIOS CONSTANTES", anio_base, "-Q", trimestre_base, ")"),
      col.names = c("PERÍODO", "MUJERES", "VARONES"),
      align = "c")

# ============================================================
# 9. GRÁFICO COMPARATIVO (NOMINAL VS REAL) - OPCIONAL
# ============================================================
ggplot(patrones_trimestre, aes(x = factor(paste(ANO4, TRIMESTRE, sep="-Q")))) +
  # Ingreso real
  geom_line(aes(y = ingreso_real, color = Sexo, group = Sexo, linetype = "Real"), size = 1.2) +
  geom_point(aes(y = ingreso_real, color = Sexo), size = 2) +
  
  # Ingreso nominal (opcional, para comparar)
  geom_line(aes(y = ingreso_nominal, color = Sexo, group = Sexo, linetype = "Nominal"), 
            size = 0.8, alpha = 0.5) +
  
  labs(
    title = "COMPARACIÓN: INGRESO NOMINAL VS REAL DE PATRONES",
    subtitle = paste("ARGENTINA - TRIMESTRAL 2019 A 2025 (PRECIOS CONSTANTES", anio_base, "-Q", trimestre_base, ")"),
    x = "PERÍODO (AÑO-TRIMESTRE)",
    y = "INGRESO PROMEDIO (PESOS)",
    color = "SEXO",
    linetype = "TIPO DE INGRESO",
    caption = "FUENTE: EPH - INDEC | AJUSTE POR IPC"
  ) +
  theme_minimal() +
  theme(
    legend.position = "bottom",
    plot.title = element_text(face = "bold", size = 14),
    axis.text.x = element_text(angle = 90, hjust = 1, size = 8)
  ) +
  scale_y_continuous(labels = scales::comma)

# ============================================================
# 10. GUARDAR RESULTADOS (OPCIONAL)
# ============================================================
# Guardar tabla como CSV
write_csv(tabla_patrones_real, "tabla_patrones_ingreso_real.csv")

# Guardar datos procesados
saveRDS(promedio_trimestre, "promedio_trimestre_eph.rds")

3.4. Visualización de datos: - Incluir un gráfico generado con ggplot2. - Mostrar el código utilizado para la creación del gráfico. 4. Interpretación de la visualización - Incluir una interpretación mínima del gráfico presentado. 5. Elaborar una breve devolución y crítica en relación a los contenidos del taller, metodología, modalidad, etc. (Aquello que consideren conveniente mencionar para mejorar el mismo).

## # A tibble: 6 × 7
##    ANO4 TRIMESTRE periodo CATEGORIA_OCUPACIONAL Sexo    ingreso_nominal
##   <dbl>     <dbl> <chr>   <chr>                 <chr>             <dbl>
## 1  2019         1 2019-Q1 Cuenta propia         Mujeres          13221.
## 2  2019         1 2019-Q1 Cuenta propia         Varones          17522.
## 3  2019         1 2019-Q1 Obrero o empleado     Mujeres          17360.
## 4  2019         1 2019-Q1 Obrero o empleado     Varones          23289.
## 5  2019         1 2019-Q1 Patron                Mujeres          32727.
## 6  2019         1 2019-Q1 Patron                Varones          45798.
## # ℹ 1 more variable: n_observaciones <int>
## # A tibble: 28 × 3
##     ANO4 TRIMESTRE   ipc
##    <dbl>     <int> <dbl>
##  1  2019         1  197.
##  2  2019         2  219.
##  3  2019         3  241.
##  4  2019         4  273.
##  5  2020         1  297.
##  6  2020         2  316.
##  7  2020         3  337.
##  8  2020         4  372.
##  9  2021         1  418.
## 10  2021         2  469.
## # ℹ 18 more rows
## # A tibble: 6 × 10
##    ANO4 TRIMESTRE periodo CATEGORIA_OCUPACIONAL Sexo    ingreso_nominal
##   <dbl>     <dbl> <chr>   <chr>                 <chr>             <dbl>
## 1  2019         1 2019-Q1 Cuenta propia         Mujeres          13221.
## 2  2019         1 2019-Q1 Cuenta propia         Varones          17522.
## 3  2019         1 2019-Q1 Obrero o empleado     Mujeres          17360.
## 4  2019         1 2019-Q1 Obrero o empleado     Varones          23289.
## 5  2019         1 2019-Q1 Patron                Mujeres          32727.
## 6  2019         1 2019-Q1 Patron                Varones          45798.
## # ℹ 4 more variables: n_observaciones <int>, ipc <dbl>, ingreso_real <dbl>,
## #   factor_deflactor <dbl>
## [1] "INFLACIÓN ACUMULADA DESDE 2019-Q1 (%):"
## # A tibble: 28 × 3
##     ANO4 TRIMESTRE inflacion_acumulada
##    <dbl>     <int>               <dbl>
##  1  2019         1                 0  
##  2  2019         2                11.1
##  3  2019         3                22.2
##  4  2019         4                38.2
##  5  2020         1                50.4
##  6  2020         2                59.9
##  7  2020         3                70.8
##  8  2020         4                88.5
##  9  2021         1               112. 
## 10  2021         2               137. 
## 11  2021         3               160. 
## 12  2021         4               185. 
## 13  2022         1               223. 
## 14  2022         2               282. 
## 15  2022         3               361. 
## 16  2022         4               447. 
## 17  2023         1               553. 
## 18  2023         2               714. 
## 19  2023         3               941. 
## 20  2023         4              1393. 
## 21  2024         1              2339. 
## 22  2024         2              2982. 
## 23  2024         3              3380. 
## 24  2024         4              3698. 
## 25  2025         1              3998. 
## 26  2025         2              4316. 
## 27  2025         3              4560. 
## 28  2025         4              4892.

INGRESO REAL DE PATRONES POR SEXO (PRECIOS CONSTANTES 2025 -Q 3 )
PERÍODO MUJERES VARONES
2019-Q1 1,525,050 2,134,112
2019-Q2 1,256,409 1,941,744
2019-Q3 1,246,132 1,822,459
2019-Q4 1,124,015 1,713,964
2020-Q1 1,103,814 1,523,563
2020-Q2 1,129,373 1,677,160
2020-Q3 1,014,702 1,504,951
2020-Q4 1,322,342 1,242,241
2021-Q1 942,595 1,642,431
2021-Q2 968,131 1,852,961
2021-Q3 1,392,393 1,619,080
2021-Q4 1,226,520 2,976,997
2022-Q1 1,104,226 1,520,125
2022-Q2 1,083,390 1,350,345
2022-Q3 1,061,498 1,455,619
2022-Q4 1,074,055 1,270,365
2023-Q1 1,183,217 1,347,025
2023-Q2 942,011 1,486,255
2023-Q3 946,676 1,492,159
2023-Q4 904,438 1,499,594
2024-Q1 758,622 1,368,391
2024-Q2 929,051 1,506,830
2024-Q3 1,575,011 1,531,627
2024-Q4 1,556,554 1,619,813
2025-Q1 1,207,883 2,134,012
2025-Q2 2,542,501 2,408,812
2025-Q3 1,653,724 2,277,090
TENDENCIAS DEL INGRESO REAL DE PATRONES (2019-2025)
SEXO PENDIENTE CREC/TRIM CREC/ANUAL ING. INICIAL ING. FINAL CAMBIO %
Mujeres 11165.72 11165.72 44662.90 0.06 1525050 1653724 8.44
Varones 1669.79 1669.79 6679.15 0.00 2134112 2277090 6.70