ggplot_footnote_summary: : Format a given plot by adding a summary of the data as a...

Description Usage Arguments Examples

Description

: A function that, given a ggplot object, list of summaries (each obtained using summary() in base R), a name for each summary object and an output file, returns (and saves) a version of the plot with a the summary (summaries) at the bottom of the plot.

Usage

1
2
3
ggplot_footnote_summary(ggplt, summary_list, summary_title_vec, ndigit = 3,
  font = "Helvetica", font_size = 8, font_color = "#3A3F3F",
  output_file = NA)

Arguments

ggplt

The ggplot to which the summary(summaries) are to be appended (ggplot2 object)

summary_list

The list of summaries obtained using summary() (list of summary() object [technically same as data type being summarized])

summary_title_vec

Vector of strings to be used as titles for the summary (summaries) (vector/array of character)

ndigit

Decimal precision to use in writing the summary statistics (integer)

font

fontfamily used in writing footnote, "Helvetica" by default (character)

font_size

footnote text size, 8 by default (numeric)

font_color

color of footnote text, dark gray by default (character expressing hex or RGB color)

output_file

Path and filename to save resulting plot with footnote as (NA, means don't save - default) (character)

Examples

1
2
3
4
5
6
## Not run: 
gender_summary <- list(summary(dem[gender == "female", ]$age), summary(dem[gender == "male", ]$age))
age_distribution <- ggplot(data = dem, aes(x = age, color = factor(gender))) + geom_density()
plot_summ <- ggplot_footnote_summary(ggplt = age_distribution, summary_list = gender_summary, summary_title_vec = c("Female", "   Male"), output_file = "age_distribution_by_gender.pdf")

## End(Not run)

ClaraMarquardt/ehR documentation built on May 6, 2019, 12:02 p.m.