| build_grid | R Documentation |
Build a grob consort diagram, use this if you want
to save plots with ggsave. Splits can be nested to
any depth.
build_grid(x, shrink_to_fit = FALSE)
x |
A consort object. |
shrink_to_fit |
If |
The diagram is laid out at a fixed, device-independent "natural" size,
returned (in inches) as the size attribute of the result, which
can be passed straight to ggsave's width/
height for an undistorted export, e.g.
sz <- attr(build_grid(x), "size"); ggsave(..., width = sz$width, height = sz$height).
With shrink_to_fit = TRUE, the diagram is scaled down (text, boxes
and spacing together, never enlarged) to fit the currently open graphics
device; this is what plot.consort uses so an interactive
plot window never ends up with overlapping nodes.
A gList object, with a size attribute giving the
diagram's natural width/height in inches.
gList
## Not run:
txt1 <- "Population (n=300)"
txt1_side <- "Excluded (n=15): \n
\u2022 MRI not collected (n=3)\n
\u2022 Tissues not collected (n=4)\n
\u2022 Other (n=8)"
g <- add_box(txt = txt1)
g <- add_side_box(g, txt = txt1_side)
g <- add_box(g, txt = "Randomized (n=200)")
gr <- build_grid(g)
sz <- attr(gr, "size")
# ggsave("consort_diagram.pdf", plot = gr, width = sz$width, height = sz$height)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.