Package 'StrategyUnitTheme'

Title: Strategy Unit Theme
Description: This package provides ggplot2 themes and colour palettes for use by The Strategy Unit.
Authors: Tom Jemmett [aut, cre] (ORCID: <https://orcid.org/0000-0002-6943-2990>), Stacey Croft [aut], The Strategy Unit [cph]
Maintainer: Tom Jemmett <[email protected]>
License: MIT + file LICENSE
Version: 0.1.7
Built: 2026-05-12 05:31:05 UTC
Source: https://github.com/The-Strategy-Unit/StrategyUnitTheme

Help Index


Convert to an Strategy Unit Word document

Description

Format for converting from R Markdown to a Strategy Unit branded MS Word document.

Usage

su_document(
  use_numbered_headings = FALSE,
  toc = FALSE,
  toc_depth = 1,
  fig_caption = TRUE,
  df_print = "kable",
  highlight = "default",
  keep_md = FALSE,
  md_extensions = NULL,
  pandoc_args = NULL
)

Arguments

use_numbered_headings

should we use numbered headings? Defaults to false

toc

TRUE to include a table of contents in the output

toc_depth

Depth of headers to include in table of contents

fig_caption

TRUE to render figures with captions

df_print

Method to be used for printing data frames. Valid values include "default", "kable", "tibble", and "paged". The "default" method uses a corresponding S3 method of print, typically print.data.frame. The "kable" method uses the knitr::kable function. The "tibble" method uses the tibble package to print a summary of the data frame. The "paged" method creates a paginated HTML table (note that this method is only valid for formats that produce HTML). In addition to the named methods you can also pass an arbitrary function to be used for printing data frames. You can disable the df_print behavior entirely by setting the option rmarkdown.df_print to FALSE. See Data frame printing section in bookdown book for examples.

highlight

Syntax highlighting style. Supported styles include "default", "tango", "pygments", "kate", "monochrome", "espresso", "zenburn", and "haddock". Pass NULL to prevent syntax highlighting.

keep_md

Keep the markdown file generated by knitting.

md_extensions

Markdown extensions to be added or removed from the default definition or R Markdown. See the rmarkdown_format for additional details.

pandoc_args

Additional command line options to pass to pandoc

Details

See the online documentation for additional details on using the word_document format.

Value

R Markdown output format to pass to render

Examples

## Not run: 
library(rmarkdown)

# simple invocation
render("input.Rmd", su_document())

## End(Not run)

Convert to an Strategy Unit xaringan presentation

Description

Format for converting from R Markdown to a Strategy Unit branded xaringan presentation.

Usage

su_presentation(...)

Arguments

...

additional arguments to pass to [xaringan::moon_reader()]

Value

R Markdown output format to pass to render

Examples

## Not run: 
library(rmarkdown)

# simple invocation
render("input.Rmd", su_presentation())

## End(Not run)

Creates the Strategy Unit Theme for ggplot

Description

Creates a base theme for ggplot objects. By default this uses a font that requires the extrafont package to be installed.

Usage

su_theme(base_family = "Segoe UI")

Arguments

base_family

The font to use in this theme

Examples

## Not run: 
library(ggplot2)
library(StrategyUnitTheme)
ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) +
  geom_point() +
  su_theme()

## End(Not run)

Strategy Unit Theme Colours

Description

This function returns the colours that are used in the Strategy Unit theme as a named vector of RGB values in hexadecimal form.

Usage

su_theme_cols(
  ...,
  palette = c(NA, "main", "oranges", "charcoals", "slates", "reds", "blues")
)

Arguments

...

individual colours that you wish to get the values of

palette

a name of a palette to select the colours of

Details

If no arguments are passed to the function, then all of the colours are returned. If only specific colours are required, then the names of the colours that are required can be passed as strings to the function, and only those colours will be returned.

If a "pallete" is selected then no arguments should be passed to ...

Only one palete can be selected at a time.

Value

a named vector of RGB colours in hexadecimal form

Examples

# show all of the colours
su_theme_cols()
# or, just show some colours
su_theme_cols("orange", "red", "grey")
# or, select a single palette
su_theme_cols(palette = "slates")

Strategy Unit Theme Gradient colour Scale

Description

Generates a two colour gradient (low-high)

Usage

scale_colour_su(
  palette = c("main", "oranges", "charcoals", "slates", "reds", "blues"),
  discrete = TRUE,
  reverse = FALSE,
  ...
)

scale_color_su(
  palette = c("main", "oranges", "charcoals", "slates", "reds", "blues"),
  discrete = TRUE,
  reverse = FALSE,
  ...
)

scale_fill_su(
  palette = c("main", "oranges", "charcoals", "slates", "reds", "blues"),
  discrete = TRUE,
  reverse = FALSE,
  ...
)

Arguments

palette

The name of palette to use

discrete

Optional: boolean to indicate that this scale is a discrete scale. Defaults to TRUE

reverse

Optional: boolean to reverse the direction of the scale. Defaults to FALSE

...

additional arguments passed to the ggplot functions

Value

a scale object to be used with a ggplot object


Strategy Unit Theme Palettes

Description

This function returns a palette generated by colorRampPalette from one of the Strategy Unit palettes

Usage

su_theme_pal(
  palette = c("main", "oranges", "charcoals", "slates", "reds", "blues"),
  reverse = FALSE,
  ...
)

Arguments

palette

The name of palette to use

reverse

Optional: boolean value to reverse the palette

...

arguments to pass to colorRamp

Value

A colorRamp function

Examples

su_theme_pal()
# or, specify a paltte
su_theme_pal("oranges")
# a reverse palette
su_theme_pal("slates", TRUE)