# NOT RUN {
cat(f_wrap('really long label names are the pits'))
cat(f_wrap('really long label names are the pits', width = 20, exdent = 2))
f_wrap(c('really long label names are the pits and make us sad',
'not nearly so long'), equal.lines = TRUE)
# }
# NOT RUN {
library(tidyverse); library(gridExtra)
set.seed(10)
dat <- data_frame(
level = c('Not Involved', 'Somewhat Involved Single Group',
'Somewhat Involved Multiple Groups', 'Very Involved One Group',
'Very Involved Multiple Groups'
),
n = sample(1:10, length(level))
) %>%
mutate(
level = factor(level, levels = unique(level)),
`%` = n/sum(n)
)
gridExtra::grid.arrange(
dat %>%
ggplot(aes(level, `%`)) +
geom_col() +
labs(title = 'Yucky Labels', y = NULL),
dat %>%
ggplot(aes(level, `%`)) +
geom_col() +
scale_x_discrete(labels = f_wrap) +
scale_y_continuous(labels = ff_prop2percent(digits = 0)) +
labs(title = 'Happy Labels', y = NULL),
ncol = 1, heights = c(.45, .55)
)
# }
Run the code above in your browser using DataLab