Description Usage Arguments Value See Also Examples
Wrap strings by splitting n width, and paste collapsing with new line characters.
1 2 3 4 5 6 7 8 9 10 11 12 |
x |
A vector of text strings. |
width |
A positive integer giving the target column for wrapping lines in the output. |
sep |
A new line separator (defaults to |
exdent |
A non-negative integer specifying the indentation of subsequent lines in paragraphs. |
indent |
A non-negative integer giving the indentation of the first line in a paragraph. |
equal.lines |
logical. If |
collapse |
logical. If |
... |
Other arguments passed to |
Returns a string vector with wrapped new line characters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 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)
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.