Learn R Programming

timeline (version 0.9)

timeline: Creates a timeline plot.

Description

This function will create a timeline using the ggplot2 framework in a style similar to Preceden. There are two types of events, those that have a range (i.e. a start and end date) and and points-in-time. The latter can be grouped in separate rows to prevent overlapping or to organize different types of events. Grouping of point-in-time events will color code those events accordingly.

Usage

timeline(df, events, label.col = names(df)[1], group.col = names(df)[2], start.col = names(df)[3], end.col = names(df)[4], text.size = 4, text.color = "black", num.label.steps = 5, event.label.col, event.col, event.group.col, event.spots = 1, event.label = "", event.label.method = 1, event.line = FALSE, event.text.size = 4, event.above = TRUE, limits, ...)

Arguments

df
data for time periods.
events
data for events (optional).
label.col
the column name in df to use for labeling.
group.col
the column name in df to use for grouping.
start.col
the column name in df that specifies the start date.
end.col
the column name in df that specifies the end date.
text.size
the text size for labels in df.
text.color
the text color for labels in df.
num.label.steps
the number of steps to use for labeling events.
event.label.col
the column name in events to use for labeling.
event.col
the column name in events that specifies the date.
event.group.col
the column name in events to use for grouping.
event.spots
the number of rows to use for events. Note that each group in df is equal to one, so event.spots = 2 would be twice as high as one group row from df.
event.label
the label to use on the x-axis for events.
event.label.method
the labeling method. For method = 1 labels are printed horizontally; for method = 2 labels are printed at 45 degree angles.
event.line
whether to draw a vertical line for each event.
event.text.size
the text size for event labels.
event.above
whether events should be plotted above (TRUE) or below (FALSE) time bars.
limits
the limits of the y-axis.
...
currently unused.

Examples

Run this code
data(ww2)
timeline(ww2, ww2.events)
timeline(ww2, ww2.events, event.spots=2, event.label='', event.above=FALSE)

Run the code above in your browser using DataLab