species_to_italics: Italicise species names

View source: R/species_to_latin.R

species_to_italicsR Documentation

Italicise species names

Description

Italicises species names, but not modifiers such as "var."

Usage

species_to_italics(
  x,
  families = TRUE,
  modifiers = c("spp", "sp", "fo", "var", "agg"),
  postfix = c("-type", "-t"),
  etc = character(0),
  first_with_dot_only = TRUE,
  first_capital_only = TRUE,
  no_numbers = TRUE,
  no_extra_capitals = TRUE,
  not_after_capital = TRUE,
  text = TRUE
)

Arguments

x

character; one or more species names to be italicised

families

logical; should family names be italicised

modifiers

character; vector of taxonomic terms not to italicise

postfix

character; text appended to species names that should not be italicised

etc

character; vector of other words that should not be italicised

first_with_dot_only

logical;

first_capital_only

logical; if TRUE only the first word starting with a capital letter is italicised

no_numbers

logical; if TRUE any words with numbers are not italicised

no_extra_capitals

logical; if TRUE any words with capitals other than first letter are not italicised

not_after_capital

logical; if TRUE, nothing after first extra capital is capitalised

text

logical; TRUE gives output as character vector; FALSE gives list of expressions

Details

Uses various heuristics to identify which parts of the name should be italicised and which should not. Should identify authority (if present) by the presence of the capital letter. Will probably fail with informal names unless included in 'etc'.

Value

A character vector if “text' is TRUE, otherwise a list of expressions.

Examples

species_to_italics(c("Navicula spp.", "Navicula spp", "Poaceae"))
library(ggplot2)
library(dplyr)
library(tidyr)
data(SWAP, package = "rioja")
SWAP$spec %>% mutate(pH = SWAP$pH) %>%
pivot_longer(cols = -pH, names_to = "taxa", values_to = "percent") %>%
  left_join(as_tibble(SWAP$names), by = c("taxa" = "CODE")) %>%
  group_by(taxa) %>%
  filter(sum(percent > 0) > 60, max(percent) > 20) %>%
  ggplot(aes(x = pH, y = percent)) +
  geom_point() +
  facet_wrap(~TaxonName,
             labeller = as_labeller(
               species_to_italics,
               default = label_parsed))

richardjtelford/ggpalaeo documentation built on Nov. 7, 2022, 11:03 p.m.