GMRI Logo

 

GMRI R Style Doc

Accessing GMRI styles

This package contains various functions for quickly accessing GMRI styles, colors, and themes.

To add a GMRI css stylesheet to an Rmarkdown File, simple use the function use_gmri_styles() and indicate which css stylesheet you wish to add.

Adding a Header

The function: insert_gmri_header() was created to insert a header file into an rmarkdown document or shiny app. This function was conceived to work by printing an html file located in the gmRi/inst/stylesheets directory in-place into the .Rmd or shiny file. Currently it only works succesfully with shiny apps.

This function should be run in the first code block in the document, prior to any outputs or text. The html header will be inserted in place, so any text above it will remain above it.

Currently this function fails for rmarkdown files because it is unable to locate the .png file for the logo to display correctly. Perhaps a friendly collaborator could remedy this…

An alternative way to add a header is by including it in the www subfolder of a .Rmd file. Then in the YAML header it can be referenced directly with:

output:
html_document:
includes:
in_header: www/header.html
before_body: www/doc_prefix.html
after_body: www/doc_suffix.html

If it references an image file make sure the path is also www/image.png and that the file is in that folder.

OR alternatively you can add html, or images directly by including it directly via a path to a subfolder and referencing them in the subfolder.

Example: The following line of html code will attach the GMRI logo to the right of the document, the top-right when included at the start of an .Rmd doc.

Attaching CSS File from gmRi Package

The CSS file determines what fonts, colors, sizes, spacing, and margins should be applied to different elements throughout the document. The default css file will apply the GMRI font to the headers, and apply some GMRI colors to various rmarkdown elements.

This can be placed anywhere in the document except in the setup code block. It is helpful to place this line of code with other formatting options near the top of the document.

An alternative function use_gmri_style_shiny exists for linking a stylesheet to a Shiny Application. This function has two alternative calls for attaching a header or footer as well.

Including GMRI Colors in Plots

You can also access GMRI colors in ggplot through some additional functions for accessing brand colorways.

Discrete Colors Manually

Available GMRI colors can be accessed by running gmri_cols() without any arguments. This function can also be used to return the hex values of a desired color by name. This is helpful for manual insertion of specific colors.

Interpolated Colors

There are also 2 functions for interpolating colors using several palettes, these are scale_fill_gmri() and scale_color_gmri().