tidyverse / haven

Read SPSS, Stata and SAS files from R
https://haven.tidyverse.org
Other
423 stars 115 forks source link

Labelled column headers are right aligned in tibble output #676

Closed MokeEire closed 2 years ago

MokeEire commented 2 years ago

Column headers for labelled columns are right aligned in console tibble output which can make it difficult to interpret which values are associated with which column. See below:

image

col3 is almost above the values of col4, making it difficult to read.

Hopefully useful reprex

library(purrr)
library(tibble)
library(haven)

# Combine labelled columns into tibble
map_dfc(paste0("col", 1:4), 
        # Create labelled column
        ~tibble(!!.x := labelled(sample(c(1,5,8,9), 20, replace = T),
                                 labels = c(Yes = 1, No = 5,
                                            `Don't know` = 8,
                                            Refused = 9))))
gorcha commented 2 years ago

Hey @MokeEire,

Thanks for the change request! haven defaults to right alignment since these are ultimately double variables, but agree that left alignment makes more sense in most cases once labels are included.