Standardize data to plot on a timeline plot

vistime_data(
  data,
  col.event = "event",
  col.start = "start",
  col.end = "end",
  col.group = "group",
  col.color = "color",
  col.fontcolor = "fontcolor",
  col.tooltip = "tooltip",
  optimize_y = TRUE,
  ...
)

Arguments

data

data.frame that contains the data to be normalized

col.event

(optional, character) the column name in data that contains event names. Default: event.

col.start

(optional, character) the column name in data that contains start dates. Default: start.

col.end

(optional, character) the column name in data that contains end dates. Default: end.

col.group

(optional, character) the column name in data to be used for grouping. Default: group.

col.color

(optional, character) the column name in data that contains colors for events. Default: color, if not present, colors are chosen via RColorBrewer.

col.fontcolor

(optional, character) the column name in data that contains the font color for event labels. Default: fontcolor, if not present, color will be black.

col.tooltip

(optional, character) the column name in data that contains the mouseover tooltips for the events. Default: tooltip, if not present, then tooltips are built from event name and date.

optimize_y

(optional, logical) distribute events on y-axis by smart heuristic (default), otherwise use order of input data.

...

for deprecated arguments up to vistime 1.1.0 (like events, colors, ...)

Value

vistime_data returns a data.frame with the following columns: event, start, end, group, tooltip, label, col, fontcol, subplot, y

Examples

# presidents and vice presidents
pres <- data.frame(
  Position = rep(c("President", "Vice"), each = 3),
  Name = c("Washington", rep(c("Adams", "Jefferson"), 2), "Burr"),
  start = c("1789-03-29", "1797-02-03", "1801-02-03"),
  end = c("1797-02-03", "1801-02-03", "1809-02-03"),
  color = c("#cbb69d", "#603913", "#c69c6e"),
  fontcolor = c("black", "white", "black")
)

vistime_data(pres, col.event = "Position", col.group = "Name")
#>       event      start        end      group
#> 1 President 1789-03-29 1797-02-03 Washington
#> 2      Vice 1789-03-29 1797-02-03      Adams
#> 3 President 1797-02-03 1801-02-03      Adams
#> 4      Vice 1797-02-03 1801-02-03  Jefferson
#> 5 President 1801-02-03 1809-02-03  Jefferson
#> 6      Vice 1801-02-03 1809-02-03       Burr
#>                                                           tooltip     label
#> 1 <b>President</b><br>from <b>1789-03-29</b> to <b>1797-02-03</b> President
#> 2      <b>Vice</b><br>from <b>1789-03-29</b> to <b>1797-02-03</b>      Vice
#> 3 <b>President</b><br>from <b>1797-02-03</b> to <b>1801-02-03</b> President
#> 4      <b>Vice</b><br>from <b>1797-02-03</b> to <b>1801-02-03</b>      Vice
#> 5 <b>President</b><br>from <b>1801-02-03</b> to <b>1809-02-03</b> President
#> 6      <b>Vice</b><br>from <b>1801-02-03</b> to <b>1809-02-03</b>      Vice
#>       col fontcol subplot y
#> 1 #cbb69d   black       1 7
#> 2 #cbb69d   black       2 5
#> 3 #603913   white       2 5
#> 4 #603913   white       3 3
#> 5 #c69c6e   black       3 3
#> 6 #c69c6e   black       4 1