proyecto-clase.R

Published on Oct 17, 2026

proyecto-clase.R

proyecto-clase.R - PDF to Podcast

Published on Oct 17, 2026

Description:

Welcome to Data Walkthrough. Today we're opening an R session built around the Encuesta Nacional de Calidad de Vida 2023, the ECV 2023, and looking at the first descriptive steps.
And the first reality check is scale. The imported data frame has 240,212 rows and 79 columns.
The script loads tidyverse, haven, readxl, and moments. The tidyverse startup message lists dplyr, readr, forcats, stringr, ggplot2, tibble, lubridate, tidyr, and purrr.
The startup message also flags that dplyr::filter masks stats::filter and dplyr::lag masks stats::lag. That's a familiar toolkit for first-pass exploratory analysis, and the masking note is a useful reminder to be explicit about which function you mean.
The file path points to 'Características y composición del hogar.CSV'. The read call uses a semicolon delimiter and treats empty strings and 'NA' as missing.
The structure output confirms a spec_tbl_df with 240,212 observations and 79 variables, including identifiers like DIRECTORIO and SECUENCIA_ENCUESTA.
Before we interpret anything, I want to flag the biggest limitation: this is console output, not a codebook. We can report the numbers, but we should not invent category labels.
The comments do label P6040 as age and P6020 as sex at birth. But for most other variables, we only see codes and frequencies in the excerpt.
For age, P6040 runs from 0 to 104. The first quartile is 16, the median is 33, and the third quartile is 52.
The mean is 34.72911 and the standard deviation is 22.27101. So the mean sits slightly above the median, which fits a distribution with a longer right tail.
The script calculates skewness at 0.3498559 and excess kurtosis at -0.8297019.
In plain terms, that's a modest positive skew and a flatter-than-normal distribution. The age range is wide, so an average near 35 is only one part of the story.
The plots include a histogram with five-year bins and a boxplot. The histogram is titled 'Distribución de la edad' with the subtitle 'Encuesta Nacional de Calidad de Vida 2023'.
A five-year binwidth is a reasonable first look here, but I'd also want to see age split by household relationship before drawing conclusions.
The P6020 table has two codes. Code 1 has 116,098 records and code 2 has 124,114. The percentage table reports 48.33 and 51.67.
That's a fairly balanced split at the whole-file level, but because the excerpt does not print the code labels, I would not name the categories beyond the source's 'sex at birth' label.
The script also checks P6051 and P5502. P6051 shows 14 response codes, with code 1 at 86,405 and code 3 at 82,155. P5502 shows six codes plus 35,452 missing values.
Those frequencies are useful for data quality checks, but they are not substantive findings until we know what the codes mean.
The variable list includes housing-related names such as P1894 through P1905 and P1927. The structure output also shows a block of logical columns around P3510 and character columns like P755S1 and P5667.
That mix of types is a good reminder to inspect missingness and import decisions before modeling or even tabulating.
So the strongest takeaway is procedural. This is a clean first-pass descriptive workflow: import, check dimensions, summarize, plot, and inspect variable types.
My caution is just as important: don't turn code frequencies into social claims without the questionnaire or codebook. The numbers are real; the labels are incomplete.
That's our walkthrough. Next, we'd want the codebook before interpreting P6051, P5502, or the housing variables.