View source: R/striptext_lines.r
lines.striptext | R Documentation |
Counts lines of striptext. Returns length two integer
indicating the highest number of lines encountered, per axis.
Line breaks are literal newlines, but also implied
where multiple columns exist per list element.
See also striptext
.
## S3 method for class 'striptext'
lines(x, ...)
x |
list with class 'striptext' |
... |
passed arguments |
length one integer
library(magrittr)
library(dplyr)
library(ggplot2)
(
mtcars %>%
ggplot(aes(wt, mpg)) +
geom_point()
) %>% striptext %>% lines
(
mtcars %>%
ggplot(aes(wt, mpg)) +
geom_point() +
facet_grid(cyl ~ am + gear)
) %>% striptext %>% lines
(
mtcars %>%
ggplot(aes(wt, mpg)) +
geom_point() +
facet_wrap(. ~ cyl + am + gear)
) %>% striptext %>% lines
(
mtcars %>%
ggplot(aes(wt, mpg)) +
geom_point() +
facet_wrap(
. ~ cyl + am + gear,
labeller = labeller(
.default = label_both
)
)
) %>% striptext %>% lines
(
mtcars %>%
ggplot(aes(wt, mpg)) +
geom_point() +
facet_wrap(
. ~ cyl + am + gear,
labeller = labeller(
.default = label_both,
.multi_line = FALSE
)
)
) %>% striptext %>% lines
## Not run:
\donttest{
(
mtcars %>%
ggplot(aes(wt, mpg)) +
geom_point() +
facet_wrap(
. ~ cyl + am + gear,
labeller = purrr::partial(
label_both,
sep = "\n"
)
)
) %>% striptext %>% lines
}
## End(Not run)
(
mtcars %>%
mutate(cyl = paste('cylinders:', cyl)) %>%
mutate(gear = paste('gears:', gear)) %>%
mutate(am = paste('transmission:', am))%>%
ggplot(aes(wt, mpg)) +
geom_point() +
facet_wrap(
. ~ cyl + am + gear,
labeller = labeller(
.default = label_wrap_gen(10),
.multi_line = TRUE
)
)
) %>% striptext %>% lines
(
mtcars %>%
mutate(cyl = paste(sep = '\n', 'cylinders', cyl)) %>%
mutate(gear = paste(sep = '\n', 'gears', gear)) %>%
mutate(am = paste(sep = '\n', 'transmission', am))%>%
ggplot(aes(wt, mpg)) +
geom_point() +
facet_wrap(
. ~ cyl + am + gear,
labeller = labeller(
.default = label_wrap_gen(10)
)
)
) %>% striptext %>% lines
(
mtcars %>%
mutate(cyl = paste(sep = ':', 'cylinders', cyl)) %>%
mutate(gear = paste(sep = ':', 'gears', gear)) %>%
mutate(am = paste(sep = ':', 'transmission', am))%>%
ggplot(aes(wt, mpg)) +
geom_point() +
facet_wrap(
. ~ paste(sep = '\n', cyl, am, gear),
)
) %>% striptext %>% lines
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.