Last active
April 17, 2019 21:42
-
-
Save crsh/db06d3cc81599d92fda6 to your computer and use it in GitHub Desktop.
Demonstration of variable.labels attribute in RStudio Viewer and Hmisc::label
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| label_test <- cars | |
| attr(label_test, "variable.labels") <- c("Speed (km/h)", "Distance traveled (km)") | |
| View(label_test) | |
| str(label_test) # data.frame attribute | |
| # Alternative using Hmisc (does not show up in RStudio Viewer) | |
| label_test <- cars | |
| Hmisc::label(label_test$speed) <- "Speed (km/h)" | |
| Hmisc::label(label_test$dist) <- "Distance traveled (km)" | |
| str(label_test) # Column specific attributes |
Author
crsh
commented
Oct 8, 2015

The package haven also uses an attribute called label for each variable to import labels from SPSS, STATA, or SAS.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment