Title: | Remove Weekends and Holidays from ggplot2 Axes |
---|---|
Description: | Provides a continuous date scale, omitting weekends and holidays. |
Authors: | Dave Mills [aut, cre] |
Maintainer: | Dave Mills <[email protected]> |
License: | GPL-2 |
Version: | 2.0.0 |
Built: | 2024-11-22 03:20:57 UTC |
Source: | https://github.com/dvmlls/bdscale |
The periods are:
years
quarters
months
weeks
days
bd_breaks(business.dates, n.max = 5)
bd_breaks(business.dates, n.max = 5)
business.dates |
a vector of |
n.max |
the maximum number of breaks to return |
returns a function function: max => [date range] => breaks
that generates the breaks
for the interval with the largest number of breaks less than n.max
Date
s into your business-date scale.Transform Date
s into your business-date scale.
bd2t(dates, business.dates)
bd2t(dates, business.dates)
dates |
a |
business.dates |
a vector of |
returns an integer vector where each element is the number of business days t
after the first date in your business.dates
vector
monday <- as.Date('2014-10-13') weekdays <- monday + 0:4 bd2t(monday + c(1, 3), weekdays)
monday <- as.Date('2014-10-13') weekdays <- monday + 0:4 bd2t(monday + c(1, 3), weekdays)
Trading dates for the New York Stock Exchange extracted from the close prices of the S&P 500.
nyse
nyse
A vector of 16657 Date
objects, starting on 1950-01-03 and ending on 2016-03-15
https://finance.yahoo.com/q/hp?s=SPY+Historical+Prices
Weekend- and holiday-ignoring position scale for a ggplot.
scale_x_bd(..., business.dates, max.major.breaks = 5, max.minor.breaks = max.major.breaks * 5, breaks = bd_breaks(business.dates))
scale_x_bd(..., business.dates, max.major.breaks = 5, max.minor.breaks = max.major.breaks * 5, breaks = bd_breaks(business.dates))
... |
other arguments passed to |
business.dates |
a vector of |
max.major.breaks |
maximum major breaks |
max.minor.breaks |
maximum minor breaks |
breaks |
a function |
## Not run: ggplot(ts, aes(x=date, y=price)) + scale_x_bd(business.dates=yahoo('SPY'), max.major.breaks=10, labels=date_format("%b '%y")) ## End(Not run)
## Not run: ggplot(ts, aes(x=date, y=price)) + scale_x_bd(business.dates=yahoo('SPY'), max.major.breaks=10, labels=date_format("%b '%y")) ## End(Not run)
Get past trading days using close prices of supplied ticker
yahoo(ticker = "^GSPC")
yahoo(ticker = "^GSPC")
ticker |
The ticker you want to use, defaults to S&P 500: |
returns a vector of Date
s