Learn R Programming

gridify (version 0.7.4)

print,gridifyClass-method: Print method for gridifyClass

Description

Method for printing a gridifyClass object. Prevents the show method from being triggered.

Usage

# S4 method for gridifyClass
print(x, ...)

Value

Invisibly a grid call used to draw the object.

Arguments

x

A gridifyClass object.

...

Additional arguments. Not yet in use.

See Also

gridify(), set_cell()

Examples

Run this code
# (to use |> version 4.1.0 of R is required, for lower versions we recommend %>% from magrittr)
library(magrittr)

g <- gridify(
  object = ggplot2::ggplot(data = mtcars, ggplot2::aes(x = mpg, y = wt)) +
    ggplot2::geom_line(),
  layout = simple_layout()
) %>%
  set_cell("title", "TITLE")

print(g)

# grid call is returned when printed to a variable
gg <- print(g)
# unevaluated grid code
gg
# evaluate the code
grid::grid.draw(eval(gg, envir = attr(gg, "env")))
# or
OBJECT <- attr(gg, "env")[["OBJECT"]]
grid::grid.draw(eval(gg))

Run the code above in your browser using DataLab