ymdShade: Shading Date Ranges

Description Usage Arguments Value See Also Examples

View source: R/ymdShade.R

Description

ymdXy returns a list of x and y coordinates that can be fed to polygon to draw NBER shadings on the current plot. If the last row of the ymds argument has a Start entry but an "NA" End entry and openShade is FALSE, the returned list will not have coordinates for the last row, but will instead include a vLine element that gives the x coordinate of the last Start. If openShade is TRUE (the default), the list includes x and y coordinates for the last row of ymds, using the second element of the horizontal range determined by the xrange parameter as its end time.

ymdShade shades date ranges on the current tisPlot. on the current plot. It calls ymdXy to get x and y coordinates for the areas to be shaded and then passes those coordinates along with its own arguments to polygon to do the shading. It also draws a vertical line at the appropriate location if the list returned by ymdXy has a vLine element.

Usage

1
2
3
ymdShade(ymds, col = grey(0.8), border = FALSE, xpd = FALSE,
          xrange = NULL, openShade = TRUE, ...)
ymdXy(ymds, xrange = NULL, openShade = TRUE)

Arguments

All but ymds are passed along to polygon:

ymds

a matrix of yyyymmdd dates with two columns named 'Start' and 'End' that specifies the date ranges to be shaded. nberDates() produces a suitable matrix.

col

color to shade recessionary periods

border

the default (FALSE) omits borders on the shaded regions. TRUE draws borders in the foreground color. Alternatively, specify a border color.

xpd

should clipping take place?

...

other args passed to polygon

xrange

horizontal range over which recession shading should be drawn. The default value NULL uses the entire range of the plot. Note however the tisPlot uses the range of the data, which will generally differ the plot range unless the tisPlot parameters leftExpandBy and rightExpandBy are zero. You can force tisPlot to use the plot range by setting the parameter nberArgs = list(xrange = NULL).

openShade

governs how ymdXy and consequently ymdShade handle the case where the last row of the ymds matrix has an NA in the "End" column, indicating that the end date of the most recent shaded period is not known.

Value

As described above, ymdXy returns a list. ymdShade does not return anything useful.

See Also

polygon

Examples

1
2
3
4
    require("datasets")
    plot(presidents, type='n', ylab="Presidents approval rating")
    ymdShade(nberDates())
    lines(presidents)

Example output



tis documentation built on Sept. 29, 2021, 1:06 a.m.