forked from ClaraMarquardt/ehR
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathggplot_footnote_summary.Rd
37 lines (30 loc) · 1.88 KB
/
ggplot_footnote_summary.Rd
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ggplot_footnote_summary.R
\name{ggplot_footnote_summary}
\alias{ggplot_footnote_summary}
\title{: Format a given plot by adding a summary of the data as a footnote.}
\usage{
ggplot_footnote_summary(ggplt, summary_list, summary_title_vec, ndigit = 3,
font = "Helvetica", font_size = 8, font_color = "#3A3F3F",
output_file = NA)
}
\arguments{
\item{ggplt}{The ggplot to which the summary(summaries) are to be appended (ggplot2 object)}
\item{summary_list}{The list of summaries obtained using summary() (list of summary() object [technically same as data type being summarized])}
\item{summary_title_vec}{Vector of strings to be used as titles for the summary (summaries) (vector/array of character)}
\item{ndigit}{Decimal precision to use in writing the summary statistics (integer)}
\item{font}{fontfamily used in writing footnote, "Helvetica" by default (character)}
\item{font_size}{footnote text size, 8 by default (numeric)}
\item{font_color}{color of footnote text, dark gray by default (character expressing hex or RGB color)}
\item{output_file}{Path and filename to save resulting plot with footnote as (NA, means don't save - default) (character)}
}
\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.
}
\examples{
\dontrun{
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")
}
}