Is there a way to view data in RStudio data viewer and have labelled vectors showing value labels?

85 views Asked by At

I am using data in the form of a tibble with almost entirely categorical factors, each containing value labels for each factor levels. I would like to convert one of my factors to a labelled vector using the haven::labelled() command with value labels and a variable label specified. When the variable is in factor format, I can use the RStudio data viewer to view my tibble and see the value labels displayed, but when I convert the variable to a haven_labelled vector, the value labels do not appear in the data viewer, only the variable label. Is there a way to get the value labels for a haven_labelled vector to appear in the data viewer?

Also, I am planning to eventually export the tibble to various formats (csv, xlsx, dta) for my collaborators to use. Can anyone describe the nuances of representing variables as haven_labelled vectors with value labels vs. factors with value labels when exporting data and opening them in other applications like Excel, Stata?

1

There are 1 answers

0
mirirai On

As far as I know, rstudios data viewer is not capable of showing value labels. You might write a feature request on github though. https://github.com/rstudio/rstudio/issues

When you print a tibble with value labelled variables in the console, the (shortend) labels are shown side by side to the values.