ggcognigen
July 9, 2024 ยท View on GitHub
ggcognigen provides geoms, themes, styles, and helper functions for {ggplot2} at the Clinical Pharmacology and Pharmacometrics (CPP) business unit of Simulations Plus, Inc.
Load it with:
library(ggcognigen)
Functionality
Themes
CPP themes are based on ggplot2::theme_bw(). Additional theme() inputs can be passed to ... for further customization.
theme_cognigen(): simple theme for CPP plots (without grid lines).theme_cognigen_grid(): similar totheme_cognigen()but displaying grid lines in the background.
Geoms
Additional geom functions:
geom_barcount(): a utility function working in combination withgeom_bar()and allowing the display of the (possibly cumulative) count, normalized count, or percentages of the data represented by each bar.geom_boxplot2(): a variant onggplot2::geom_boxplot()allowing users to set whisker limits based upon a confidence interval rather than a multiple of the IQR, display outliers with jitter, and providing a slightly different graphical styles for grouping/coloring.geom_boxcount(): a utility function working in combination withgeom_boxplot2()allowing the display of the number of data points used for the calculation of statistics which are graphically represented by each box and whiskers.geom_histcount(): a utility function working in combination withgeom_histogram()and allowing the display of the cumulative count, density, or percentage of data in each histogram bar.
Stats
Additional stat functions:
stat_barcount(): associated withgeom_barcount.stat_bin2(): a variant ofggplot2::bin()which exports thepercentvariable in addition to the defaultcountanddensityvariables. Mostly intended to be used withggplot2::geom_histogram()andstat_histcount()when percentages are required.stat_count2(): a variant ofggplot2::count()which exports thepercentvariable in addition to the defaultcountandpropvariables. Mostly intended to be used withggplot2::geom_bar()andstat_barcount()when percentages are required.stat_boxplot2(): a variant ofggplot2::stat_boxplot()which supportsgeom_boxplot2().stat_boxcount(): associated withgeom_boxcount().stat_histcount(): associated withgeom_histcount().
Positions
New position function:
position_fillpercent(): a variant ofggplot2::position_fill()which normalizes the data to 100 instead of 1. Mostly intended for use withggplot2::geom_bar()andgeom_barcount()for display of data in percentages.
Style and scale functions for mapping aesthetics
These control aesthetics that are mapped to data such as color, fill, linetype, shape, and size.
cognigen_style()scale_discrete_cognigen()set_default_style()read_style()
Forest plots
Additional functions for creation of forest plots:
make_gmr_data(): a function to calculate and report geometric means (GM) and geometric mean ratios (GMR).make_gmr_table(): a function to format and write GMR table (typically created bymake_gmr_data()) to html, docx, or tex files.make_forestplot(): a function to create a forest plot as aggplot2object and based upon the GRM table created bymake_gmr_data().
Miscellaneous helper functions
ggsave_multiple(): extension ofggplot2::ggsaveto save multiple plots and multi-page plots like those created usingggforce::facet_grid_paginate()orggforce::facet_wrap_paginate().get_device_size(): a utility function returning default device dimensions based upon a number of plots/panels per page.format_continuous_cognigen(): a utility function be passed to thelabelsargument of ascale_function in order to automatically format axis ticks numerical labels in default or scientific notation (beyond pre-defined value limits)