Learn R Programming

gridify (version 0.7.4)

pharma_layout_base: Base Function for Pharma Layouts

Description

This function sets up the general structure for positioning text elements for pharma layouts. It defines the layout with specified margins, global graphical parameters, and height adjustment. The layout includes cells for headers, titles, footers, and optional elements like watermarks.

Usage

pharma_layout_base(
  margin = grid::unit(c(t = 1, r = 1, b = 1, l = 1), units = "inches"),
  global_gpar = NULL,
  background = grid::get.gpar()$fill,
  adjust_height = TRUE
)

Value

A gridifyLayout object that defines the general structure and parameters for a pharma layout.

Arguments

margin

A grid::unit object defining the margins of the layout (top, right, bottom, left) in inches. Default is grid::unit(c(1, 1, 1, 1), "inches").

global_gpar

A list specifying global graphical parameters to change in the layout. Default is NULL, however the defaults in the layout are: fontfamily = "Serif", fontsize = 9 and lineheight = 0.95, which can be overwritten alongside other graphical parameters found by grid::get.gpar().

background

A string specifying the background fill colour. Default grid::get.gpar()$fill for a white background.

adjust_height

A logical value indicating whether to adjust the height of the layout. Default is TRUE.

Details

This function is primarily used internally by other layout functions such as pharma_layout_A4() and pharma_layout_letter() to create specific layouts.

See Also

pharma_layout, pharma_layout_A4(), pharma_layout_letter()

Examples

Run this code
# Create a general pharma layout with default settings
pharma_layout_base()

library(magrittr)
# Customize margins and global graphical parameters and fill all cells
gridify(
  object = ggplot2::ggplot(data = mtcars, ggplot2::aes(x = mpg, y = wt)) +
    ggplot2::geom_line(),
  layout = pharma_layout_base(
    margin = grid::unit(c(0.5, 0.5, 0.5, 0.5), "inches"),
    global_gpar = list(col = "blue", fontsize = 10)
  )
) %>%
  set_cell("header_left_1", "My Company") %>%
  set_cell("header_left_2", " / ") %>%
  set_cell("header_left_3", "") %>%
  set_cell("header_right_1", "CONFIDENTIAL") %>%
  set_cell("header_right_2", "") %>%
  set_cell("header_right_3", "Data Cut-off: YYYY-MM-DD") %>%
  set_cell("output_num", " xx.xx.xx") %>%
  set_cell("title_1", "") %>%
  set_cell("title_2", "<Title 2>") %>%
  set_cell("title_3", "<Optional Title 3>") %>%
  set_cell("by_line", "By: <GROUP>, <optionally: Demographic parameters>") %>%
  set_cell("note", "<Note or Footnotes>") %>%
  set_cell("references", "<References:>") %>%
  set_cell("footer_left", "Program: <PROGRAM NAME>, YYYY-MM-DD at HH:MM") %>%
  set_cell("footer_right", "Page xx of nn") %>%
  set_cell("watermark", "DRAFT")

Run the code above in your browser using DataLab