add_label_image {chronochrt}R Documentation

Provide image labels for a chronological chart

Description

The function creates a tibble with the paths of the image labels to be plotted in a chronological chart or adds them to an already existing tibble.

Usage

add_label_image(
  data,
  region,
  year,
  position = 0.75,
  image_path,
  new = FALSE,
  ...
)

Arguments

data

An object to which labels should be added. Must not be provided if new = FALSE.

region

A character string or character vector with the titles of the sections the label(s) should be placed in.

year

A number or a numeric vector with the year(s) at which the label should be placed (i.e. its vertical position).

position

A number or a numeric vector with the horizontal position(s) of the label. See Details for explanation.

image_path

A character string or character vector with the file path(s) or URL(s) to the image files.

new

Logical operator. If TRUE, a new data set will be created. If FALSE, the default, the input will be added to an existing data set.

...

Further columns to include or additional arguments passed to tibble or add_row.

Details

If the input is in the same order as the arguments, the arguments do not need to be explicitly named. Values can be provided as a number or character string, if they are the same for all other data. If not, they must be provided as vectors with equal lengths.

Value

A tibble with image labels ready-to-use for plotting with plot_chronochrt.

Examples

# Create new label data set
labels <- add_label_image(region = "A",
                          year = -50,
                          position = 0.5,
                          image_path = "https://www.r-project.org/logo/Rlogo.png",
                          new = TRUE)

# Add labels to existing data set
labels <- add_label_image(data = labels,
                          region = "B",
                          year = 50,
                          position = 0.9,
                          image_path = "https://www.r-project.org/logo/Rlogo.png",
                          new = FALSE)

# They can be linked using the pipe operator \code{%>%}:
library(magrittr)

labels <- add_label_image(region = "A",
                          year = -50,
                          position = 0.5,
                          image_path = "https://www.r-project.org/logo/Rlogo.png",
                          new = TRUE) %>%
          add_label_image(region = "B",
                          year = 50,
                          position = 0.9,
                          image_path = "https://www.r-project.org/logo/Rlogo.png")

[Package chronochrt version 0.1.3 Index]