8  Escalas

8.1 Escalas

Nos basaremos en el paquete de obtención de cuadros y tablas.

Escala básica

source('C:/Users/rober/Documents/R/ts.brb.test/Rprofile.site')

==========================
  Motor Barbwin8 cargado 
==========================
source('C:/Users/rober/Documents/R/ts.brb.test/functions.R')

data <- read_spss('data/datos_ejemplo.sav')

8.1.1 Absolutos

digits=NULL
data %>% 
     tab_cols('|'=unvr(P6A)) %>% 
     tab_stat_cases(label=var_lab(data$P6A),total_row_position = 'none') %>% 
     tab_cols('|'=unvr(P6B)) %>% 
     tab_stat_cases(label=var_lab(data$P6B),total_row_position = 'none') %>% 
     tab_cols('|'=unvr(P6C)) %>% 
     tab_stat_cases(label=var_lab(data$P6C),total_row_position = 'none') %>% 
     tab_cols('|'=unvr(P6D)) %>% 
     tab_stat_cases(label=var_lab(data$P6D),total_row_position = 'none') %>% 
     tab_pivot()
 montaña   costa/playa   ciudad   campo 
 #Total 
   Primer lugar elegido  160 96 72 56
   Segundo lugar elegido  80 144 64 96
   Tercer lugar elegido  64 132 52 136
   Cuarto lugar elegido  80 12 196 96
#total_col <- rowSums(as.data.frame(tab[,-1]))
#total_rows <- colSums(as.data.frame(tab[,-1]))
#total_col
#total_rows

8.1.2 Porcentajes

expss_digits(digits=1)
data %>% 
     tab_cols('|'=unvr(P6A)) %>% 
     tab_stat_rpct(label=var_lab(data$P6A),total_row_position = 'none') %>% 
     tab_cols('|'=unvr(P6B)) %>% 
     tab_stat_rpct(label=var_lab(data$P6B),total_row_position = 'none') %>% 
     tab_cols('|'=unvr(P6C)) %>% 
     tab_stat_rpct(label=var_lab(data$P6C),total_row_position = 'none') %>% 
     tab_cols('|'=unvr(P6D)) %>% 
     tab_stat_rpct(label=var_lab(data$P6D),total_row_position = 'none') %>% 
     tab_pivot()
 montaña   costa/playa   ciudad   campo 
 #Total 
   Primer lugar elegido  41.7 25 18.8 14.6
   Segundo lugar elegido  20.8 37.5 16.7 25
   Tercer lugar elegido  16.7 34.4 13.5 35.4
   Cuarto lugar elegido  20.8 3.1 51 25
expss_digits(digits=NULL)

8.1.3 Otros

expss_digits(digits=2)
data %>% 
    tab_cells(P6A,P6B,P6C,P6D) %>%
    tab_cols(total(label = "|")) %>% 
    tab_stat_fun(
        "Mean" = w_mean,
        "Std. dev." = w_sd,
        "Valid N" = w_n,
        "Maximo" = w_max,
        "Mínimo" = w_min,
        "Variance" = w_var,
        "Median" = w_median,
        "Mad" = w_mad,
        "Sum" = w_sum,
        method = list
    ) %>% 
    tab_pivot()
 Mean   Std. dev.   Valid N   Maximo   Mínimo   Variance   Median   Mad   Sum 
 Primer lugar elegido  2.06 1.09 384 4 1 1.19 2 1.48 792
 Segundo lugar elegido  2.46 1.08 384 4 1 1.17 2 1.48 944
 Tercer lugar elegido  2.68 1.12 384 4 1 1.26 2 1.48 1028
 Cuarto lugar elegido  2.80 1.04 384 4 1 1.08 3 0.00 1076
expss_digits(digits=NULL)