4 Tablas cruzadas
A diferencia de lo visto en la sección 3, en este epígrafe analizaremos como obtener cuadros resumen en los que existen variables en la cabecera, que determinan grupos o perfiles de análisis y existen variables en las filas, de las cuáles queremos conocer cómo se distribuyen sus alternativas de respuesta entre los diferentes perfiles o grupos que determinan las variables de columna. Al igual que sucedió con las tablas marginales, mostraremos poco a poco como trabajar con variables de respuesta simple, múltiple o con medidas estadísticas. Vamos a utilizar otros campos que se localizan en la base de datos del CIS (P3, P21A01, P21A02, P21A03, P31, P33). Aquí su resumen… -nótese que se ha incluido la función suppressMessages()
para no publicar los mensajes de carga del paquete y datos-.
suppressMessages(setwd("~/R/r-projects/00.tables")) #esta es la carpeta donde almacené el archivo (en una subcarpeta llamada data)
suppressMessages(library(expss)) #cargamos el paquete
suppressMessages(data <- read_spss("data/3192.sav")) #cargamos los datos
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
## Warning in type.convert.default(val_labs, numerals = "no.loss"): 'as.is' should
## be specified by the caller; using TRUE
$P3 data
## LABEL: Escala de satisfacción (1-10) con el funcionamiento del sistema sanitario español
## VALUES:
## 6, 7, 8, 8, 7, 5, 7, 7, 8, 7, 7, 6, 6, 7, 7, 6, 5, 8, 7, 7, 8, 10, 8, 6, 6, 9, 8, 8, 7, 6, 9, 6, 8, 8, 6, 7, 7, 5, 8, 6, 6, 8, 4, 4, 5, 7, 7, 8, 10, 7... 50 items printed out of 2557
## VALUE LABELS:
## 1 1 Muy insatisfecho/a
## 2 2
## 3 3
## 4 4
## 5 5
## 6 6
## 7 7
## 8 8
## 9 9
## 10 10 Muy satisfecho/a
## 98 N.S.
## 99 N.C.
$P21A01 data
## LABEL: Medicamentos que recetan por adelantado (para que no falten)
## VALUES:
## 0, 0, 0, 0, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 0, NA, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... 50 items printed out of 2557
## VALUE LABELS:
## 0 N.P.
## 1 Menciona
$P21A02 data
## LABEL: Envases que han quedado sin usar porque cambiaron el tratamiento
## VALUES:
## 0, 0, 0, 0, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, NA, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... 50 items printed out of 2557
## VALUE LABELS:
## 0 N.P.
## 1 Menciona
$P21A03 data
## LABEL: Medicamentos que decidió no tomar
## VALUES:
## 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0... 50 items printed out of 2557
## VALUE LABELS:
## 0 N.P.
## 1 Menciona
$P31 data
## LABEL: Sexo de la persona entrevistada
## VALUES:
## 2, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2... 50 items printed out of 2557
## VALUE LABELS:
## 1 Hombre
## 2 Mujer
$P33 data
## LABEL: Estado civil de la persona entrevistada
## VALUES:
## 1, 1, 1, 1, 3, 2, 2, 2, 1, 9, 1, 2, 1, 1, 3, 2, 3, 1, 1, 1, 1, 1, 1, 2, 2, 3, 2, 1, 1, 2, 2, 2, 1, 2, 1, 3, 1, 1, 1, 1, 5, 1, 1, 1, 1, 2, 5, 1, 5, 1... 50 items printed out of 2557
## VALUE LABELS:
## 1 Casado/a
## 2 Soltero/a
## 3 Viudo/a
## 4 Separado/a
## 5 Divorciado/a
## 9 N.C.
4.1 Básica con variables simples
Las tablas que vamos a hacer a continuación, siempre son tablas en las que intervienen al menos dos variables. Una de las variables irá a columnas y la otra variable irá a filas. De ellas se calcularán las frecuencias absolutas o relativas y/o los estadísticos. Vamos a empezar sólo con el estadístico frecuencias, y posteriormente ya pasaremos a estadísticos como la media, suma, etc…
4.1.1 De frecuencias, variable simple y sólo absolutos
Usaremos la variable P31 para las columnas, P33 en las celdas (de la que se hará el cálculo)y el estadístico a usar será el nº de casos.
as.datatable_widget(data %>%
tab_cells(P33) %>%
tab_cols(total(), P31) %>%
tab_stat_cases(total_row_position = "above", total_label = "Total") %>%
tab_pivot())
Figura 4.1: Cruce de estado civil por sexo
4.1.2 De frecuencias, variable simple, con porcentajes de columna
Al igual que hicimos con las tablas marginales vamos a repetir esta tabla, pero en porcentaje de columna (vertical).
as.datatable_widget(data %>%
tab_cells(P33) %>%
tab_cols(total(), P31) %>%
tab_stat_cpct(total_row_position = "above", total_label = "Total") %>% # aquí señalo los porcentajes de columna
tab_pivot())
Figura 4.2: Cruce de estado civil por sexo, porcentaje de columna
4.1.3 De frecuencias, variable simple, con porcentajes de fila
Al igual que hicimos con las tablas marginales vamos a repetir esta tabla, pero en porcentaje de fila (horizontal).
as.datatable_widget(data %>%
tab_cells(P33) %>%
tab_cols(total(), P31) %>%
tab_stat_rpct(total_row_position = "above", total_label = "Total") %>% # aquí señalo los porcentajes de fila
tab_pivot())
Figura 4.3: Cruce de estado civil por sexo, porcentaje de fila
4.1.4 De frecuencias, variable simple, con porcentajes total muestra
Al igual que hicimos con las tablas marginales vamos a repetir esta tabla, pero en porcentaje sobre el total de la muestra.
as.datatable_widget(data %>%
tab_cells(P33) %>%
tab_cols(total(), P31) %>%
tab_stat_tpct(total_row_position = "above", total_label = "Total") %>% # aquí señalo los porcentajes total muestra
tab_pivot())
Figura 4.4: Cruce de estado civil por sexo, porcentaje sobre el total de la muestra
4.1.5 Combinaciones de los anteriores
Vamos ahora a hacer combinaciones entre ellos. Advierto que cada vez se dificulta más la tabla en su lectura. Como dije inicialmente, me decanto más por tablas sencillas y con un sólo dato.
as.datatable_widget(data %>%
tab_cells(P33) %>%
tab_cols(total(), P31) %>%
tab_stat_cases(label = "Casos") %>%
tab_stat_cpct(label = "% casos") %>%
tab_pivot(stat_position = "inside_columns"))
Figura 4.5: Combinación de casos y porcentajes dentro de las columnas
Y la misma tabla pero con los estadísticos en las filas combinando frecuencia y porcentaje…
as.datatable_widget(data %>%
tab_cells(P33) %>%
tab_cols(total(), P31) %>%
tab_stat_cases(label = "Casos") %>%
tab_stat_cpct(label = "% casos") %>%
tab_pivot(stat_position = "outside_columns"))
Figura 4.6: Combinación de casos y porcentajes por tipo de estadístico en columnas
Y la misma tabla pero con los estadísticos en las filas combinando frecuencia y porcentaje…
as.datatable_widget(data %>%
tab_cells(P33) %>%
tab_cols(total(), P31) %>%
tab_stat_cases(label = "Casos") %>%
tab_stat_cpct(label = "% casos") %>%
tab_pivot(stat_position = "inside_rows"))
Figura 4.7: Combinación de casos y porcentajes dentro de las filas
Y la misma tabla pero con los estadísticos en las filas por bloque de tipo de estadístico…
as.datatable_widget(data %>%
tab_cells(P33) %>%
tab_cols(total(), P31) %>%
tab_stat_cases(label = "Casos") %>%
tab_stat_cpct(label = "% casos") %>%
tab_pivot(stat_position = "outside_rows"))
Figura 4.8: Combinación de casos y porcentajes, por tipo de estadístico en filas
4.2 Básica con múltiples
Vamos a realizar ahora el mismo conjunto de tablas, pero en las filas, en lugar de una variable de tipo simple, vamos a utilizar una variable de tipo múltiple. Repetimos los cruces pero cambiamos las celdas donde ahora usaremos la variable P21A con la instrucción tab_cells(mdset(P21A01 %to% P21A03))
.
4.2.1 De frecuencias, variable múltiple y sólo absolutos
as.datatable_widget(data %>%
tab_cells(mdset(P21A01 %to% P21A03)) %>%
tab_cols(total(), P31) %>%
tab_stat_cases(total_row_position = "above", total_label = "Total") %>%
tab_pivot())
Figura 4.9: Cruce de motivos guardar envases enteros por sexo
4.2.2 De frecuencias, variable múltiple, con porcentajes de columna
Al igual que hicimos con las tablas marginales vamos a repetir esta tabla, pero en porcentaje de columna (vertical).
as.datatable_widget(data %>%
tab_cells(mdset(P21A01 %to% P21A03)) %>%
tab_cols(total(), P31) %>%
tab_stat_cpct(total_row_position = "above", total_label = "Total") %>% # aquí señalo los porcentajes de columna
tab_pivot())
Figura 4.10: Cruce de motivos guardar envases enteros por sexo, porcentaje de columna
4.2.3 De frecuencias, variable múltiple, con porcentajes de fila
Al igual que hicimos con las tablas marginales vamos a repetir esta tabla, pero en porcentaje de fila (horizontal).
as.datatable_widget(data %>%
tab_cells(mdset(P21A01 %to% P21A03)) %>%
tab_cols(total(), P31) %>%
tab_stat_rpct(total_row_position = "above", total_label = "Total") %>% # aquí señalo los porcentajes de fila
tab_pivot())
Figura 4.11: Cruce de motivos guardar envases enteros por sexo, porcentaje de fila
4.2.4 De frecuencias, variable múltiple, con porcentajes total muestra
Al igual que hicimos con las tablas marginales vamos a repetir esta tabla, pero en porcentaje sobre el total de la muestra.
as.datatable_widget(data %>%
tab_cells(mdset(P21A01 %to% P21A03)) %>%
tab_cols(total(), P31) %>%
tab_stat_tpct(total_row_position = "above", total_label = "Total") %>% # aquí señalo los porcentajes total muestra
tab_pivot())
Figura 4.12: Cruce de motivos guardar envases enteros por sexo, porcentaje sobre el total de la muestra
4.2.5 Combinaciones de los anteriores
Vamos ahora a hacer combinaciones entre ellos. Advierto que cada vez se dificulta más la tabla en su lectura. Como dije inicialmente, me decanto más por tablas sencillas y con un sólo dato.
as.datatable_widget(data %>%
tab_cells(mdset(P21A01 %to% P21A03)) %>%
tab_cols(total(), P31) %>%
tab_stat_cases(label = "Casos") %>%
tab_stat_cpct(label = "% casos") %>%
tab_pivot(stat_position = "inside_columns"))
Figura 4.13: Combinación de casos y porcentajes dentro de las columnas
Y la misma tabla pero con los estadísticos en las filas combinando frecuencia y porcentaje…
as.datatable_widget(data %>%
tab_cells(mdset(P21A01 %to% P21A03)) %>%
tab_cols(total(), P31) %>%
tab_stat_cases(label = "Casos") %>%
tab_stat_cpct(label = "% casos") %>%
tab_pivot(stat_position = "outside_columns"))
Figura 4.14: Combinación de casos y porcentajes por tipo de estadístico en columnas
Y la misma tabla pero con los estadísticos en las filas combinando frecuencia y porcentaje…
as.datatable_widget(data %>%
tab_cells(mdset(P21A01 %to% P21A03)) %>%
tab_cols(total(), P31) %>%
tab_stat_cases(label = "Casos") %>%
tab_stat_cpct(label = "% casos") %>%
tab_pivot(stat_position = "inside_rows"))
Figura 4.15: Combinación de casos y porcentajes dentro de las filas
Y la misma tabla pero con los estadísticos en las filas por bloque de tipo de estadístico…
as.datatable_widget(data %>%
tab_cells(mdset(P21A01 %to% P21A03)) %>%
tab_cols(total(), P31) %>%
tab_stat_cases(label = "Casos") %>%
tab_stat_cpct(label = "% casos") %>%
tab_pivot(stat_position = "outside_rows"))
Figura 4.16: Combinación de casos y porcentajes, por tipo de estadístico en filas
Recordamos que siempre con las múltiples existe la posibilidad de calcular los porcentajes con base respuesta en lugar de con base cuestionario (individuos). Para ello debes utilizar tab_stat_cpct_responses()
.
4.3 Básica con estadísticos
Del mismo modo que antes utilizábamos la tabla cruzada para obtener los casos de intersección entre las categorías de columna y las categorías de fila, ahora procederemos a hacer lo mismo pero con categorías en columnas y cálculo de estadísticos básicos en otro. En definitiva, calcular las medidas estadísticas para cada grupo creado por la variable que general las categorías.
4.3.1 Cruce entre variable simple y dos estadísticos
Vamos a comenzar con las más simples, dos estadísticos (media y desviación) de una variable métrica (P3) calculados para una variable (P31) que genera dos categorías (hombre y mujer). Nótese el juego a realizar con más de 2 estadísticos con la ubicación de los mismos.
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), P31) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot())
Figura 4.17: Cruce entre variable y estadísticos
Hagamos ahora su traspuesta, es decir ubiquemos en filas P31 y en columnas
var_lab(data$P3)="Satisfacción"
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_rows(total(),P31) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot())
Figura 4.18: Transposición de tabla
Recordemos que los estadísticos los podemos ir moviendo a nuestra necesidad para que se organicen de una forma u otra…
Dentro de las columnas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), P31) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "inside_columns"))
Figura 4.19: Estadísticos dentro de columnas
Dentro de las filas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), P31) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "inside_rows"))
Figura 4.20: Estadísticos dentro de las filas
Como columnas separadas o fuera de columnas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), P31) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "outside_columns"))
Figura 4.21: Estadísticos separados en columnas
Como filas separadas o fuera de filas…
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), P31) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "outside_rows"))
Figura 4.22: Estadísticos separados en filas
Repitamos ahora estas cuatro últimas tablas, pero en lugar de con una variable que genera grupos y de ellos se calcula la medida estadística, vamos a hacerlo con un cruce de categorías (un campo en columnas y otro en filas) y que en esos cruces, se calcule la medida estadística. Por ejemplo esta tabla me permitiría saber la media de P3 en los hombres de 18 a 25 años.
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), P31) %>%
tab_rows(P33) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot())
Figura 4.23: Uso de variable base (anidación)
y juguemos con la posición del cálculo estadística que ahora sí arrojará cuatro configuraciones diferentes.
La primera con los estadísticos fuera de las filas…
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), P31) %>%
tab_rows(P33) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "outside_rows")) # por defecto, sin lo ponemos muestra esta opción
Figura 4.24: Filas con estadístico fuera de filas
Los estadísticos dentro de las filas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), P31) %>%
tab_rows(P33) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "inside_rows"))
Figura 4.25: Filas con estadístico dentro de las filas
Los estadísticos dentro de las columnas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), P31) %>%
tab_rows(P33) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "inside_columns"))
Figura 4.26: Filas con estadísticos dentro de las columnas
Los estadísticos fuera de las columnas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), P31) %>%
tab_rows(P33) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "outside_columns"))
Figura 4.27: Filas con estadísticos fuera de las columnas
¿Hacemos lo mismo para una variable múltiple?
4.3.1.1 Tabulación cruzada (con cálculo estadístico) y múltiples
Vamos a comenzar con las más simples, dos estadísticos (media y desviación) de una variable métrica (P3) calculados para una variable múltiple (P4_1 a P4_3) que genera categorías. Nótese el juego a realizar con más de 2 estadísticos con la ubicación de los mismos.
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), mdset(P21A01 %to% P21A03)) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot())
Figura 4.28: Cruce con múltiple y estadístico (1)
Hagamos ahora su traspuesta, es decir ubiquemos en filas P21A y en columnas P3.
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_rows(total(),mdset(P21A01 %to% P21A03)) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot())
Figura 4.29: Cruce con múltiple y estadístico (2)
Recordemos que los estadísticos los podemos ir moviendo a nuestra necesidad para que se organicen de una forma u otra…
Dentro de columnas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), mdset(P21A01 %to% P21A03)) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "inside_columns"))
Figura 4.30: Cruce con múltiple y estadístico (3)
Dentro de filas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), mdset(P21A01 %to% P21A03)) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "inside_rows"))
Figura 4.31: Cruce con múltiple y estadístico (4)
Fuera de columnas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), mdset(P21A01 %to% P21A03)) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "outside_columns"))
Figura 4.32: Cruce con múltiple y estadístico (5)
Fuera de filas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), mdset(P21A01 %to% P21A03)) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "outside_rows"))
Figura 4.33: Cruce con múltiple y estadístico (6)
Repitamos ahora estas cuatro últimas tablas, pero en lugar de con una variable que genera grupos y de ellos se calcula la medida estadística, vamos a hacerlo con un cruce de categorías (un campo en columnas y otro en filas) y que en esos cruces, se calcule la medida estadística. Por ejemplo esta tabla me permitiría saber la media de P3 en los hombres de 18 a 25 años.
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), mdset(P21A01 %to% P21A03)) %>%
tab_rows(P33) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot())
Figura 4.34: Cruce con múltiple y estadístico (7)
y juguemos con la posición del cálculo estadística que ahora sí arrojará cuatro configuraciones diferentes. La primera con los estadísticos dentro de las filas es idéntica a la anterior (por defecto).
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), mdset(P21A01 %to% P21A03)) %>%
tab_rows(P33) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "outside_rows")) # por defecto, sin lo ponemos muestra esta opción
Figura 4.35: Cruce con múltiple y estadístico (8)
Los estadísticos fuera de las filas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), mdset(P21A01 %to% P21A03)) %>%
tab_rows(P33) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "inside_rows"))
Figura 4.36: Cruce con múltiple y estadístico (9)
Los estadísticos dentro de las columnas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), mdset(P21A01 %to% P21A03)) %>%
tab_rows(P33) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "inside_columns"))
Figura 4.37: Cruce con múltiple y estadístico (10)
Los estadísticos fuera de las columnas …
as.datatable_widget(data %>%
tab_cells(P3) %>%
tab_cols(total(), mdset(P21A01 %to% P21A03)) %>%
tab_rows(P33) %>%
tab_stat_mean(label = "Media") %>%
tab_stat_sd(label = "Desviación") %>%
tab_pivot(stat_position = "outside_columns"))
Figura 4.38: Cruce con múltiple y estadístico (11)
Bien, como has podido observar, el resultado no difiere cuando es múltiple a cuando es simple. Igual que hemos calculado la media y la desviación lo podemos hacer con otros estadísticos:
- media;
- desviación;
- máximo;
- mínimo;
- mediana;
- suma;
- error estándar;
- un caso especial que calcula media, desviación y el número de casos;
- y algunos otros que iremos mostrando para temas muy específicos.