add_label_text {chronochrt} | R Documentation |
Provide text labels for a chronological chart
Description
The function creates a tibble with text labels to be plotted in a chronological chart or adds them to an an already existing tibble.
Usage
add_label_text(data, region, year, position = 0.9, label, new = FALSE, ...)
Arguments
data |
An object to which labels should be added. Must not be provided
if |
region |
A character string or character vector with the 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. |
label |
A character string or character vector with the text of the label(s). |
new |
Logical operator. If |
... |
Further columns to include, or additional arguments
passed to |
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 one number or one
character string, if they are the same for all other data. If not, they must
be provided as vectors with equal lengths.
It is assumed that most of the labels will be located on the right side of
each column. The position
of a label defines it right most end to
prevent it from running outside the plotting area. Vertically, it will be
placed centred on the year
given. Text in labels can be wrapped by
inserting \n
(without blanks around it).
Value
A tibble with text labels ready-to-use in
plot_chronochrt
.
Examples
# Create new label data set
labels <- add_label_text(region = "A",
year = -50,
position = 0.5,
label = "Flood",
new = TRUE)
# Add labels to existing data set
labels <- add_label_text(data = labels,
region = "B",
year = 50,
position = 0.9,
label = "Earthquake",
new = FALSE)
# They can be linked using the pipe operator \code{%>%}:
library(magrittr)
labels <- add_label_text(region = "A",
year = -50,
position = 0.5,
label = "Flood",
new = TRUE) %>%
add_label_text(region = "B",
year = 50,
position = 0.9,
label = "Earthquake")