data(Playfair1824)
str(Playfair1824)
# Plot multiple time series with matplot()
matplot(Playfair1824$Year, Playfair1824[, -1],
pch = c("S", "W", "B", "D", "E", "I", "X", "R"),
type = "b",
xlab = "Year",
ylab = "value",
ylim = c(0, 140),
main = "Linear Chronology, Exhibiting the Revenues, Expenditure, ... from 1770 to 1824")
# main events
events <- data.frame(
start = c(1776, 1793, 1804),
end = c(1782.2, 1802, 1815.2),
event = c("American War", "War: French Republic", "War: Napoleon")
)
with(events, {
arrows(x0 = start, x1 = end,
y0 = 130, y1 = 130,
lwd = 3,
code = 3,
angle = 90, length = 0.05)
text((start+end)/2, 132, event, pos = 3)
})
Run the code above in your browser using DataLab