Package 'ratlas'

Title: ATLAS Formatting Functions and Templates
Description: Provides templates, formatting tools, and 'ggplot2' themes tailored for the Accessible Teaching, Learning, and Assessment Systems (ATLAS) organization. These templates facilitate the creation of topic guides and technical reports, while the formatting functions enable users to customize numbers and tables to meet specific requirements. Additionally, the themes ensure a uniform visual style across graphics.
Authors: W. Jake Thompson [aut, cre] , Noelle Pablo [aut], Jeffrey Hoover [aut] , University of Kansas [cph, fnd]
Maintainer: W. Jake Thompson <[email protected]>
License: GPL-3
Version: 0.1.0.9000
Built: 2024-11-08 23:19:39 UTC
Source: https://github.com/atlas-aai/ratlas

Help Index


ratlas:

Description

The ratlas package serves three main purposes:

Details

  • Project templates for topic guides and technical reports

  • Functions for formatting

  • Consistent ggplot2 themes

Author(s)

Maintainer: W. Jake Thompson [email protected] (ORCID)

Authors:

Other contributors:

  • University of Kansas [copyright holder, funder]

See Also

Useful links:


Write APA Words

Description

Confused about whether a number should be written out ("five") or use numerals ("5")? Use this function! Most useful for R Markdown in-text writing.

Usage

apa_words(x, ordinal = FALSE)

Arguments

x

The number to be printed

ordinal

Do you want the ordinal numbering (e.g., 1st, 6th, etc.)

Value

A character string

Examples

apa_words(5)
apa_words(16)
apa_words(6, ordinal = TRUE)

Append row and/or column summaries

Description

Add row and/or column summaries (e.g., total counts) to a data frame.

Usage

append_summary(df, ..., row = TRUE, col = TRUE, .f = sum, args = NULL)

Arguments

df

A data frame to append summaries to.

...

Unquoted names of columns to be included in the summary

row

logical indicating whether a summary row should be added (i.e., summarizing each column)

col

logical indicating whether a summary column should be added (i.e., summarizing each row)

.f

Function to use for calculating summaries

args

A named list of arguments to pass to .f

Value

A data frame with the summary row and/or column appended

Examples

set.seed(9416)
df <- tibble::tibble(char = letters[1:5], x = rnorm(5), y = rnorm(5))
append_summary(df, x, y, row = TRUE, col = TRUE, .f = sum)
append_summary(df, x, y, row = FALSE, .f = mean)

Combine N and Percent Columns for Accessibility

Description

Combine N and Percent Columns for Accessibility

Usage

combine_n_pct(df, n, pct, name, remove = TRUE, na_replace = NULL)

Arguments

df

A data frame that has already been sent to fmt_table()

n

The unquoted name of the column containing count values

pct

The unquoted name of the column containing percentage values

name

The name of the new combined column to be created

remove

Logical. Should the existing n and pct columns be removed?

na_replace

Character string representing how missing values should be represented.

Value

A data frame.

Examples

pcts <- tibble::tibble(Program = c("A", "B", "C", "D", "E", "F"),
               n = 0:5,
               p = 0.5 * (0:5))
pcts |>
  fmt_table() |>
  combine_n_pct(n = n, pct = p, name = "States")

DLM Linkage Level Information

Description

A dataset contain information for how linkage levels are stored in the database, their official names, and their values for scoring.

Usage

dlm_ll_info

Format

A data frame with 13 rows and 4 variables:

  • subject: The subject area for the linkage level

  • linkage_level: The linkage level name as it is stored in the database

  • name: The official linkage level name (public facing)

  • value: The value used for scoring (i.e., the linkage level order, within subject)


DLM Aliases

Description

R variable aliases for commonly used vector and values.

Usage

dlm_ll

dlm_grades

dlm_complexity

Format

An object of class character of length 7.

An object of class character of length 16.

An object of class character of length 4.

Details

dlm_ll contains all linkage level names for ELA, mathematics, and science.

dlm_grades contains all DLM grade levels.

dlm_complexity contains all complexity band names for ELA, mathematics, science, writing, and communication.


Format a String with Italics for HTML or Latex Output

Description

Format a String with Italics for HTML or Latex Output

Usage

fmt_italic(string, indicator = "*", html = TRUE)

Arguments

string

The character vector to add italics to.

indicator

The indicator for which words should be italicized

html

Logical for whether the output should be HTML. If FALSE, Latex output is provided.

Value

A character vector

Examples

fmt_italic("Make *this* italic.", html = TRUE)
fmt_italic("Make *this* italic.", html = FALSE)

Wrapper function of kableExtra::kbl

Description

Create a kable table with some reasonable ATLAS defaults.

Usage

fmt_kbl(
  x,
  booktabs = TRUE,
  linesep = "",
  centering = FALSE,
  escape = FALSE,
  position = "left",
  latex_options = "HOLD_position",
  ...
)

Arguments

x

For kable(), x is an R object, which is typically a matrix or data frame. For kables(), a list with each element being a returned value from kable().

booktabs

T/F for whether to enable the booktabs format for tables. I personally would recommend you turn this on for every latex table except some special cases.

linesep

By default, in booktabs tables, kable insert an extra space every five rows for clear display. If you don't want this feature or if you want to do it in a different pattern, you can consider change this option. The default is c(”, ”, ”, ”, '\addlinespace'). Also, if you are not using booktabs, but you want a cleaner display, you can change this to ”.

centering

T (default)/F. Whether to center tables in the table environment.

escape

Boolean; whether to escape special characters when producing HTML or LaTeX tables. When escape = FALSE, you have to make sure that special characters will not trigger syntax errors in LaTeX or HTML.

position

This is the "real" or say floating position for the latex table environment. The kable only puts tables in a table environment when a caption is provided. That is also the reason why your tables will be floating around if you specify captions for your table. Possible choices are h (here), t (top, default), b (bottom) and p (on a dedicated page).

latex_options

A character vector for LaTeX table options. Please see package vignette for more information. Possible options include basic, striped, hold_position, HOLD_position, scale_down, scale_up & repeat_header. striped will add alternative row colors to the table. It will imports LaTeX package xcolor if enabled. hold_position will "hold" the floating table to the exact position. It is useful when the LaTeX table is contained in a table environment after you specified captions in kable(). It will force the table to stay in the position where it was created in the document. A stronger version: HOLD_position requires the float package and specifies ⁠[H]⁠. scale_down is useful for super wide table. It will automatically adjust the table to page width. repeat_header in only meaningful in a longtable environment. It will let the header row repeat on every page in that long table.

...

Additional parameters passed to kableExtra::kbl().

Value

A kable object.

Examples

fmt_kbl(mtcars[, 1:3], align = c("r", "c", "r"),
  col.names = c("Column 1", "Column 2", "Column 3"),
  caption = "Example Table Title")

Wrapper function of kableExtra::row_spec

Description

Apply some default formatting to the header row of a kable table. Should be called after any calls to kableExtra::column_spec().

Usage

fmt_kbl_header(
  kable_input,
  row = 0,
  align = "c",
  extra_css = "border-bottom: 0.16em solid #111111",
  ...
)

Arguments

kable_input

Output of knitr::kable() with format specified

row

A numeric value or vector indicating which row(s) to be selected. You don't need to count in header rows or group labeling rows.

align

A character string for cell alignment. For HTML, possible values could be l, c, r plus left, center, right, justify, initial and inherit while for LaTeX, you can only choose from l, c & r.

extra_css

Extra css text to be passed into the cells of the row. Note that it's not for the whole row.

...

Additional arguments passed to kableExtra::row_spec()

Value

A kable object.

Examples

fmt_kbl(mtcars[, 1:3], align = c("r", "c", "r"),
    col.names = c("Column 1", "Column 2", "Column 3"),
    caption = "Example Table Title") |>
  kableExtra::column_spec(1, width = "20em") |>
  fmt_kbl_header()

Center and Decimal Align Tables

Description

Automatic formatting for tables that should "just work" for most use cases. For more fine-grained control, see formatting and padding.

Usage

fmt_table(
  df,
  dec_dig = 1,
  prop_dig = 3,
  corr_dig = 3,
  output = NULL,
  fmt_small = TRUE,
  max_value = NULL,
  keep_zero = FALSE
)

Arguments

df

A data frame or tibble to be formatted for printing in output.

dec_dig

The number of decimal places to include for numbers, e.g., dec_dig = 1 for 16.5.

prop_dig

The number of decimal places to include for numbers bounded between [0,1], e.g., prop_dig = 2 for .35.

corr_dig

The number of decimal places to include for numbers bounded between [-1,1], e.g., corr_dig = 3 for .205.

output

The output format of the table. One of "latex" or "html". Automatically pulled from document output type if not specified.

fmt_small

Indicator for replacing zero with < (e.g., .000 becomes ⁠<.001⁠). Default is TRUE.

max_value

If fmt_small is TRUE and a max_value is supplied, any value greater than the max_value is replaced with > (e.g., if max_value = 50, then 60 becomes ⁠>49.9⁠). The number of digits depends on either dec_digits, prop_dig, or corr_dig.

keep_zero

If fmt_small is TRUE, whether to preserve true 0s (e.g., 0.0000001 becomes ⁠<.001⁠, but 0.0000000 stays .000).

Value

A tibble with the same rows and columns as df, with numbers formatted consistently and padded for alignment when printed.

See Also

Other formatters: formatting, padding

Examples

pcts <- tibble::tibble(n = 0:5, p = 0.5 * (0:5))
pcts |> fmt_table()

Arial Narrow font name R variable aliases

Description

font_an == "⁠Arial Narrow⁠"

Usage

font_an

Format

length 1 character vector


Text and Number Formatting

Description

These formatting functions are used to format numerical values in a consistent manner. This is useful for printing numbers inline with text, as well as for formatting tables. Many of the included formatting functions were adapted from TJ Mahr's printy package.

Usage

fmt_count(x, big_interval = 3L, big_mark = ",")

fmt_digits(
  x,
  digits = 3,
  fmt_small = FALSE,
  max_value = NULL,
  keep_zero = FALSE
)

fmt_leading_zero(x)

fmt_minus(x, output = NULL)

fmt_replace_na(x, replacement = "&mdash;")

fmt_corr(x, digits, output = NULL)

fmt_prop(x, digits, fmt_small = TRUE, keep_zero = FALSE)

fmt_prop_pct(x, digits = 0, fmt_small = TRUE)

Arguments

x

Number or number string to be formatted

big_interval

Interval indicating where to place numeric dividers

big_mark

Character used as mark between big interval before the decimal

digits

Number of decimal places to retain

fmt_small

Indicator for replacing zero with < (e.g., .000 becomes ⁠<.001⁠). Default is TRUE.

max_value

If fmt_small is TRUE and a ⁠max_value is supplied⁠, any value greater than the max_value is replaced with > (e.g., if max_value = 50, then 60 becomes ⁠>49.9⁠). The number of digits depends on digits.

keep_zero

If fmt_small is TRUE, whether to preserve true 0s (e.g., 0.0000001 becomes ⁠<.001⁠, but 0.0000000 stays .000).

output

The output type for the rendered document. One of "latex" or "html".

replacement

The value to use when replacing missing values

Details

fmt_count() is a wrapper for base::prettyNum(). Prints a number with a big_mark between every big_interval.

fmt_digits() is a wrapper for base::sprintf(). Prints a number with digits number of decimal places, without losing trailing zeros, as happens with base::round().

fmt_leading_zero() removes the leading zero for decimal values.

fmt_minus() replaces hyphens with the HTML minus sign (⁠&minus;⁠).

fmt_replace_na() replaces NA values with a specified replacement. This is useful for formatting tables, when blanks are not desired. The default behavior is to replace missing values with an em-dash (⁠&mdash;⁠).

fmt_prop_pct() formats proportions as percentages. This takes a number bounded between 0 and 1, multiplies it by 100, and then rounds to the specified number of digits using fmt_digits().

Two additional formatters are provided to format numbers according to the American Psychological Association (APA) style guide. The 7th edition of the APA style guide specifies that numbers bounded between [-1, 1] should not include the leading zero (section 6.36; APA, 2020). This is the case for many types of numbers commonly used by ATLAS including correlations, proportions, probabilities, and p-values. The fmt_corr() function is used to format values bounded between [-1, 1]. Digits are first rounded to the specified number of digits using fmt_digits(), and then leading zeros are removed using fmt_leading_zero() and negative signs are replaced with fmt_minus(). The fmt_prop is very similar, but is intended for values between [0, 1]. This function also wraps fmt_digits() and fmt_leading_zero(). However, fmt_prop() also replaces small values to avoid values of 0 (e.g., .00 is replaced with ⁠< .01⁠).

Value

The updated character object of the same size as x.

References

American Psychological Association. (2020). Publication manual of the American Psychological Association (7th ed.). doi:10.1037/0000165-000

See Also

Other formatters: fmt_table(), padding

Examples

test_cor <- cor(mtcars[, 1:4])
as.character(round(test_cor[1:4, 3], 2))
fmt_digits(test_cor[1:4, 3], 2)

fmt_digits(test_cor[1:4, 3], 2) %>%
  fmt_leading_zero()

fmt_digits(test_cor[1:4, 3], 2) %>%
  fmt_minus()

fmt_digits(c(test_cor[1:4, 3], NA_real_), 2) %>%
  fmt_replace_na(replacement = "&mdash;")

fmt_corr(test_cor[1:4, 3], 2)

fmt_prop(c(0.001, 0.035, 0.683), digits = 2)

Save a ggplot2 graphic

Description

This is a wrapper around ggplot2::ggsave() with some ATLAS-specific defaults. The aspect ratio is fixed to 0.618 (the golden ratio) unless the height is manually defined. Plots are automatically spell checked and warnings are returned if there are possible mistakes. Finally, plots saved as a pdf have the fonts embedded using extrafont::embed_fonts().

Usage

ggsave2(
  plot = ggplot2::last_plot(),
  filename,
  device = NULL,
  path = NULL,
  width = 7,
  height = NULL,
  units = "in",
  dir = c("h", "v"),
  dpi = "retina",
  embed_fonts = FALSE,
  ...
)

Arguments

plot

Plot to save, defaults to last plot displayed.

filename

File name to create on disk.

device

Device to use. Can either be a device function (e.g. png), or one of "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf" (windows only). If NULL (default), the device is guessed based on the filename extension.

path

Path of the directory to save plot to: path and filename are combined to create the fully qualified file name. Defaults to the working directory.

width

Plot size in units ("in", "cm", or "mm").

height

Plot size in units ("in", "cm", or "mm"). If not supplied, uses 0.618 * width when dir = "h" and 1.618 * width when dir = "v".

units

Units of plot size ("in", "cm", or "mm"). Default is inches.

dir

Orientation of the plot. One of h (default) for horizontal or v for vertical.

dpi

Plot resolution. Also accepts a string input: "retina" (320), "print" (300), or "screen" (72). Applies only to raster output types.

embed_fonts

Logical. Use Ghostscript to embed fonts in a PDF graphic?

...

Additional arguments passed to ggplot2::ggsave()

Value

None. Called for side effects.

Examples

library(ggplot2)
p <- ggplot(mtcars, aes(mpg, wt)) +
 geom_point()

ggsave2(p, "/mtcars.pdf", path = tempdir())
ggsave2(p, "/mtcars.png", path = tempdir())

Generate a section for the yaml input

Description

Generate a section for the yaml input

Usage

inc(input, sep = "\n\n  ")

Arguments

input

a file containing markdown text

sep

a separator for each line.

Value

a string

Examples

## Not run: 
inc("front-matter/preface.Rmd")

## End(Not run)

Create an R Markdown PDF measr Report

Description

This is a function called in the output of the yaml of the Rmd file to specify using the standard measr report document formatting.

Usage

measr_pdf(...)

Arguments

...

Arguments to be passed to ⁠[bookdown::pdf_document2]⁠

Value

A modified pdf_document2 with the standard tech report formatting.

Examples

## Not run: 
output: ratlas::measr_pdf

## End(Not run)

Only If

Description

Adverb for conditionally skipping steps in a piped workflow.

Usage

only_if(condition)

Arguments

condition

Logical condition to be evaluated

Value

None. Called for side effects.

Author(s)

David Robinson, https://twitter.com/drob/status/785880369073500161

Examples

d <- tibble::as_tibble(mtcars)
d %>% only_if(TRUE)(dplyr::filter)(mpg > 25)

d %>% only_if(FALSE)(dplyr::filter)(mpg > 25)

Table Padding

Description

A family of functions for formatting numbers and then padding with spaces so that table columns can be both centered and decimal aligned.

Usage

pad_counts(x, digits = 0L)

pad_prop(x, digits, fmt_small = TRUE, keep_zero = FALSE, output = NULL)

pad_corr(x, digits, output = NULL)

pad_decimal(
  x,
  digits,
  fmt_small = FALSE,
  max_value = NULL,
  keep_zero = FALSE,
  output = NULL
)

Arguments

x

Number or number string to be formatted

digits

Number of decimal places to retain

fmt_small

Indicator for replacing zero with < (e.g., .000 becomes ⁠< .001⁠). Default is TRUE.

keep_zero

If fmt_small is TRUE, whether to preserve true 0s (e.g., 0.0000001 becomes ⁠<.001⁠, but 0.0000000 stays .000).

output

The output type for the rendered document. One of "latex" or "html".

max_value

If fmt_small is TRUE and a ⁠max_value is supplied⁠, any value greater than the max_value is replaced with > (e.g., if max_value = 50, then 60 becomes ⁠>49.9⁠). The number of digits depends on digits.

Details

pad_counts should be used to pad integer numbers. This wraps base::format() to add a comma separator.

pad_prop should be used to pad decimal numbers between [0,1]. This wraps fmt_prop() to round to a specified number of digits and optionally remove the leading zero.

pad_corr should be used to pad decimal numbers between [-1,1]. This wraps fmt_corr(), and is similar to pad_prop, but accounts for negative numbers when adding padding.

pad_decimal should be used to pad decimal number that are not bounded. This wraps fmt_digits() to round to a specified number of decimal places.

Value

A character vector of the same length as x.

See Also

Other formatters: fmt_table(), formatting

Examples

pad_counts(sample(1:1000, size = 20))

pad_prop(c(0.001, runif(5)), digits = 2)

pad_corr(runif(10, -1, 1), digits = 2)

pad_decimal(runif(10, 1, 100), digits = 1)

Official color palette for ATLAS

Description

Official brand colors for Accessible Teaching, Learning, and Assessment Systems.

Usage

palette_atlas

palette_atlas_black

Format

An object of class character of length 6.

An object of class character of length 6.


Color palette proposed by Lisa Charlotte Rost

Description

A colorblind friendly palette taken from the article What to consider when visualizing data for colorblind readers

Usage

palette_lcrost

palette_lcrost_black

Format

An object of class character of length 8.

An object of class character of length 8.


Color palette proposed by Okabe and Ito

Description

Two color palettes taken from the article "Color Universal Design" by Okabe palette_okabeito contains a gray color, while palette_okabeito_black contains black instead.

Usage

palette_okabeito

palette_okabeito_black

Format

An object of class character of length 8.

An object of class character of length 8.


Capitalization of words

Description

Capitalize the first letters of words in a string. Can either use sentence case (i.e., only the first word capitalized; all = FALSE) or title case (i.e., all words capitalized; all = TRUE).

Usage

rat_cap_words(x, all = FALSE)

Arguments

x

A character string

all

Logical. If TRUE, the first letter of every word is capitalized. If FALSE (the default), only the first word is capitalized.

Value

A character string with the specified capitalization.

Examples

name <- c("zip code", "state", "final count")
vapply(name, rat_cap_words, character(1))
vapply(name, rat_cap_words, character(1), all = TRUE)

ATLAS color scale

Description

This is a qualitative scale using the official ATLAS brand colors. See palette_atlas for details.

Arguments

...

common discrete scale parameters: name, breaks, labels, na.value, limits, guide, and aesthetics. See ggplot2::discrete_scale for more details.

use_black

If TRUE, scale includes black, otherwise includes gray.

order

Numeric vector listing the order in which the colors should be used. Default is 1:8.

darken

Relative amount by which the scale should be darkened (for positive values) or lightened (for negative values).

alpha

Alpha transparency level of the color. Default is no transparency.

Value

A color scale for use in plots created with ggplot2::ggplot().

Examples

library(ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
  geom_point() + scale_color_atlas()
ggplot(iris, aes(Sepal.Length, fill = Species)) +
  geom_density(alpha = 0.7) + scale_fill_atlas(order = c(1, 3, 5))

Lisa Charlotte Rost color scale

Description

This is a color-blind friendly, qualitative scale with eight different colors. See palette_lcrost for details. The palette was first described in this blog post.

Arguments

...

common discrete scale parameters: name, breaks, labels, na.value, limits, guide, and aesthetics. See ggplot2::discrete_scale for more details.

use_black

If TRUE, scale includes black, otherwise includes gray.

order

Numeric vector listing the order in which the colors should be used. Default is 1:8.

darken

Relative amount by which the scale should be darkened (for positive values) or lightened (for negative values).

alpha

Alpha transparency level of the color. Default is no transparency.

Value

A color scale for use in plots created with ggplot2::ggplot().

Examples

library(ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
  geom_point() + scale_color_lcrost()
ggplot(iris, aes(Sepal.Length, fill = Species)) +
  geom_density(alpha = 0.7) + scale_fill_lcrost(order = c(1, 3, 5))

Okabe-Ito color scale

Description

This is a color-blind friendly, qualitative scale with eight different colors. See palette_okabeito for details.

Arguments

...

common discrete scale parameters: name, breaks, labels, na.value, limits, guide, and aesthetics. See ggplot2::discrete_scale for more details.

use_black

If TRUE, scale includes black, otherwise includes gray.

order

Numeric vector listing the order in which the colors should be used. Default is 1:8.

darken

Relative amount by which the scale should be darkened (for positive values) or lightened (for negative values).

alpha

Alpha transparency level of the color. Default is no transparency.

Value

A color scale for use in plots created with ggplot2::ggplot().

Examples

library(ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
  geom_point() + scale_color_okabeito()
ggplot(iris, aes(Sepal.Length, fill = Species)) +
  geom_density(alpha = 0.7) + scale_fill_okabeito(order = c(1, 3, 5))

Set default ggplot2 theme

Description

Sets the default color schemes, fonts, and theme for ggplot2 plots. The default color scheme for continuous variables is the viridis color palette, and the default color scheme for discrete variables is the Okabe Ito palette.

Usage

set_theme(
  font = "Arial Narrow",
  discrete = c("okabeito", "atlas", "ggplot2"),
  continuous = c("viridis", "magma", "inferno", "plasma", "cividis", "ggplot2"),
  ...
)

Arguments

font

The base font family to be used in plots.

discrete

Color palette for discrete colors. One of "okabeito" (default), "atlas", or "ggplot2".

continuous

Color palette for continuous scales. One of "magma", "inferno", "plasma", "viridis" (default), or "cividis", or "ggplot2".

...

Additional arguments to pass to theme functions.

Value

None. Called for side effects.

Examples

set_theme("Arial Narrow")

Create an HTML Slide Deck with R Markdown

Description

This is a function called in the output of the YAML of the Rmd file to specify using the standard DLM tech report pdf document formatting.

Usage

slides_html(...)

Arguments

...

Arguments to be passed to ⁠[xaringan::moon_reader]⁠

Value

A modified mood_reader with ATLAS branding applied.

Examples

## Not run: 
output: ratlas::slides_html

## End(Not run)

Create an R Markdown GitBook Tech Report

Description

This is a function called in the output of the yaml of the Rmd file to specify using the standard DLM tech report pdf document formatting.

Usage

techreport_gitbook(...)

Arguments

...

Arguments to be passed to ⁠[bookdown::gitbook]⁠

Value

A modified gitbook with the standard tech report formatting.

Examples

## Not run: 
output: ratlas::techreport_gitbook

## End(Not run)

Create an R Markdown PDF Document Tech Report

Description

This is a function called in the output of the yaml of the Rmd file to specify using the standard DLM tech report pdf document formatting.

Usage

techreport_pdf(apa6 = FALSE, ...)

Arguments

apa6

Should the old

...

Arguments to be passed to ⁠[bookdown::pdf_document2]⁠

Value

A modified pdf_document2 with the standard tech report formatting.

Examples

## Not run: 
output: ratlas::techreport_pdf

## End(Not run)

ATLAS ggplot2 theme for consistent graphics

Description

Based on hrbrthemes::theme_ipsum.

Usage

theme_atlas(
  base_family = "Arial Narrow",
  base_size = 11.5,
  plot_title_family = base_family,
  plot_title_size = 18,
  plot_title_face = "bold",
  plot_title_margin = 10,
  subtitle_family = base_family,
  subtitle_size = 12,
  subtitle_face = "plain",
  subtitle_margin = 15,
  strip_text_family = base_family,
  strip_text_size = 12,
  strip_text_face = "plain",
  caption_family = base_family,
  caption_size = 9,
  caption_face = "italic",
  caption_margin = 10,
  axis_text_size = 9,
  axis_title_family = subtitle_family,
  axis_title_size = base_size,
  axis_title_face = "plain",
  axis_title_just = "cm",
  plot_margin = ggplot2::margin(30, 30, 30, 30),
  grid_col = "#cccccc",
  grid = TRUE,
  axis_col = "#cccccc",
  axis = FALSE,
  ticks = FALSE
)

Arguments

base_family, base_size

base font family and size

plot_title_family, plot_title_face, plot_title_size, plot_title_margin

plot title family, face, size and margin

subtitle_family, subtitle_face, subtitle_size

plot subtitle family, face and size

subtitle_margin

plot subtitle margin bottom (single numeric value)

strip_text_family, strip_text_face, strip_text_size

facet label font family, face and size

caption_family, caption_face, caption_size, caption_margin

plot caption family, face, size and margin

axis_text_size

font size of axis text

axis_title_family, axis_title_face, axis_title_size

axis title font family, face and size

axis_title_just

axis title font justification, one of ⁠[blmcrt]⁠

plot_margin

plot margin (specify with ggplot2::margin())

grid_col, axis_col

grid & axis colors; both default to ⁠#cccccc⁠

grid

panel grid (TRUE, FALSE, or a combination of X, x, Y, y)

axis

add x or y axes? TRUE, FALSE, "xy"

ticks

ticks if TRUE add ticks

Value

A theme for use in plots created with ggplot2::ggplot().

Examples

## Not run: 
library(ggplot2)
library(dplyr)

# seminal scatterplot
ggplot(mtcars, aes(mpg, wt)) +
  geom_point() +
  labs(x = "Fuel effiiency (mpg)", y = "Weight (tons)",
       title = "Seminal ggplot2 scatterplot example",
       subtitle = "A plot that is only useful for demonstration purposes",
       caption = "Brought to you by the letter 'g'") +
  theme_atlas()

# seminal bar chart

update_geom_font_defaults()

count(mpg, class) %>%
  ggplot(aes(class, n)) +
  geom_col() +
  geom_text(aes(label=n), nudge_y=3) +
  labs(x = "Fuel efficiency (mpg)", y = "Weight (tons)",
       title =  "Seminal ggplot2 bar chart example",
       subtitle = "A plot that is only useful for demonstration purposes",
       caption = "Brought to you by the letter 'g'") +
  theme_atlas(grid = "Y") +
  theme(axis.text.y = element_blank())
  
## End(Not run)

Create an R Markdown Word Document Topic Guide

Description

This is a function called in the output of the yaml of the Rmd file to specify using the standard DLM topic guide word document formatting.

Usage

topicguide_docx(...)

Arguments

...

Arguments to be passed to ⁠[bookdown::word_document2]⁠

Value

A modified word_document2 with the standard topic guide formatting.

Examples

## Not run: 
output: ratlas::topicguide_docx

## End(Not run)

Create an R Markdown PDF Topic Guide

Description

This is a function called in the output of the yaml of the Rmd file to specify using the standard DLM topic guide document formatting.

Usage

topicguide_pdf(...)

Arguments

...

Arguments to be passed to ⁠[bookdown::pdf_document2]⁠

Value

A modified pdf_document2 with the standard tech report formatting.

Examples

## Not run: 
output: ratlas::topicguide_pdf

## End(Not run)

Create an R Markdown Word Document Topic Guide

Description

This is a function called in the output of the yaml of the Rmd file to specify using the standard DLM topic guide word document formatting.

Usage

topicguide_rdocx(...)

Arguments

...

Arguments to be passed to ⁠[bookdown::word_document2]⁠

Value

A modified word_document2 with the standard topic guide formatting.

Examples

## Not run: 
output: ratlas::topicguide_rdocx

## End(Not run)

Update matching font defaults for text geoms

Description

Updates ggplot2::geom_label and ggplot2::geom_text font defaults

Usage

update_geom_font_defaults(
  family = "Arial Narrow",
  face = "plain",
  size = 3.5,
  color = "#2b2b2b"
)

Arguments

family, face, size, color

font family name, face, size and color

Value

None. Called for side effects.

Examples

# updates font to Arial Narrow, size to 3.5, and color to #2b2b2b by default
update_geom_font_defaults()