Description Usage Arguments Examples
Tag a ggplot2 or lattice (or any grid) object with meta information by nesting it within a grid framework
A wrapper for 'ggTag', specific to the pharma industry
1 2 3 4 5 6 |
object |
A ggplot or lattice object |
extractTitle |
Logical. Defaults to FALSE. Extract the title from the graph and use as plot title. |
title |
Character.You own title. Overridden if extractTitle is TRUE. |
meta |
List containing meta information to include in the 4 corners of the plot: top_left, top_right, bottom_left, bottom_right |
fontsize |
The font size in pt. Defaults to 12. |
theme |
An optional ggplot2 theme to use. Only applies to the current plot, i.e. the main theme is not updated. |
inherit_size |
Logical. If 'TRUE' the value of fontsize is passed through to the selected ggplot2 theme. |
protocol |
What is the protocol number? |
population |
What is the population? |
page |
What is the page? |
pages |
How many pages are there? |
date |
Logical. Defaults to TRUE. |
username |
Logical. Defaults to TRUE. |
path |
Logical. Defaults to TRUE. |
date_format |
Character. R date format to use for the date. |
... |
Arguments to pass to 'ggTag' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | library(grid)
library(ggplot2)
# Layout used:
grid.show.layout(
grid.layout(nrow = 3, ncol = 3,
heights = unit(c(4, 1, 3), c("lines", "null", "lines")),
widths = unit(c(.25, 1, .25), c("inches", "null", "inches"))
)
)
# Create ggplot2 graphic
my_plot <- ggplot(data = airquality,
aes(x = Wind, y = Temp)) +
geom_point() +
theme_bw() +
theme(strip.text.y = element_text(),
strip.background = element_rect(fill = NA, linetype = 0),
panel.grid.minor = element_line(colour = NA),
panel.grid.major = element_line(colour = NA)
)
my_plot
#ggTag generic use
ggTag(my_plot,
meta = list(top_left = "Protocol: 123456\nPopulation: Intent-to-Treat",
top_right = "Page 1 of 1",
bottom_left = paste(Sys.getenv("USERNAME"), getwd()),
bottom_right = date()))
# Using pharmaTag
pharmaTag(my_plot)
# Reduce font size
pharmaTag(my_plot,
protocol = "ABC123456",
population = "Intent-to-treat",
fontsize = 8)
# Change theme
pharmaTag(my_plot,
protocol = "ABC123456",
population = "Intent-to-treat",
theme = theme_grey())
# Reading in a pdf as a raster
library(png)
png_loc <- system.file(package = "ggTag", "extdata/r_logo.png")
a_png <- readPNG(png_loc)
pharmaTag(object = a_png,
protocol = "ABC123456",
population = "Intent-to-treat")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.