lines.striptext: Count Lines of Striptext

View source: R/striptext_lines.r

lines.striptextR Documentation

Count Lines of Striptext

Description

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.

Usage

## S3 method for class 'striptext'
lines(x, ...)

Arguments

x

list with class 'striptext'

...

passed arguments

Value

length one integer

Examples

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


qPharmetra/qpToolkit documentation built on May 24, 2023, 8:52 a.m.