Created
April 18, 2017 16:13
-
-
Save shv38339/17866b135f620c9ee61c7c70c4ba9e5d to your computer and use it in GitHub Desktop.
Combine list names with list levels in order to imitate the coefficient output from summary(lm(...)) objects in R (aka smushed variable names with variable levels)
This file contains 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
# place list levels in object | |
list_levels <- | |
mtcars %>% select(vs, gear) %>% | |
transmute(vs_fctr = factor(vs, labels = c("0. Zero", "1. One")), | |
gear_fctr = factor(gear, labels = c("3. Three", "4. Four", "5. Five"))) %>% | |
sapply(levels) # sapply extracts unique levels from all variables | |
# i still don't understand this code but it works... | |
lapply(seq_along(list_levels), | |
function(i) paste(names(list_levels)[[i]], list_levels[[i]], sep = "")) %>% | |
unlist() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment