sfirke / janitor

simple tools for data cleaning in R
http://sfirke.github.io/janitor/
Other
1.39k stars 133 forks source link

add labels to varnames/values as in {labelled} and {haven} #394

Open higgi13425 opened 4 years ago

higgi13425 commented 4 years ago

Feature request

Recognize variable labels and value labels as in {haven} haven packagedown site

and {labelled} labelled packagedown site

packages when printing tabyls.

It would be cool.

sfirke commented 4 years ago

I like this idea and in fact I have a basic version that I use for tabyl-ing labelled vectors, back when that was a data type I encountered more: https://github.com/sfirke/tidysurvey/issues/2#issuecomment-463262151

How does that work for you? It is just a minimal example I used in my own work and hasn't received the thought it would need to be package-ready.

(I think the note to myself about "labels(dat) <- char_vec using papeR::labels" is about how I was labeling the data coming out of SurveyMonkey and won't be relevant if you already have labelled data?)

sda030 commented 2 years ago

I strongly support recognizing {labelled} in tabyls. I am about to introduce tidyverse, janitor and more to many R-newbies who face a lot of survey data, but this limitation makes me reconsider tabyl... :(

olivroy commented 6 months ago

@sfirke I could implement a PR for this.. Display labels in tabyl() if they exist.

New support for the label attribute was recently added in RStudio. gt does this, and ggplot2 seems to be going in this direction tidyverse/ggplot2#5879

sfirke commented 6 months ago

@olivroy that would be great. I will review such a PR. Let me know if you have design questions as you go, or questions about the backend code of tabyl.