########################
# CSM Plot Functions
########################
# Load Windows Fonts (Arial)
extrafont::loadfonts(device = "win")
# Define Colors
cs_green <- rgb(0, 102, 51, maxColorValue = 255)
cs_gray <- rgb(242, 242, 242, maxColorValue = 255)
cs_darkgray <- rgb(230, 230, 230, maxColorValue = 255)
cs_axisgray <- rgb(159, 159, 159, maxColorValue = 255)
cs_orange <- "orange"
cs_lgreen <- "#32a852"
# Define Plot Theme
plot_theme <- ggplot2::theme(
text = ggplot2::element_text(
family = "Arial",
face = "bold",
color = "black",
size = 10
),
plot.title = ggplot2::element_text(
size = 12,
hjust = 0.5
),
axis.text = ggplot2::element_text(
family = "Arial Narrow",
face = "plain",
color = "black"
),
panel.grid.major.y = ggplot2::element_line(
size = 1,
linetype = "solid",
color = cs_darkgray
),
panel.grid.major.x = ggplot2::element_blank(),
panel.grid.minor = ggplot2::element_blank(),
axis.line = ggplot2::element_line(color = cs_axisgray),
panel.border = ggplot2::element_rect(
color = cs_darkgray,
fill = NA
),
panel.background = ggplot2::element_rect(
fill = cs_gray,
color = cs_gray
),
plot.caption = ggplot2::element_text(
color = cs_green,
face = "italic"
),
axis.title.x = ggplot2::element_blank(),
axis.title.y = ggplot2::element_blank(),
)
#' cSM Eco ggplot2 Theme
#'
#' This function imitates CSM Eco's chart theme
#'
#' @return A ggtheme object
#' @export
theme_csm <- function() plot_theme
#' cSM Eco ggplot2 Theme
#'
#' This function adds recession bars to ggplot using daily FRED recession indicator data
#' @param st_date Start date of desired data
#' @param ed_date End date of desired data
#' @param shade_color Color of recession bars
#' @return A geom_rect object
#' @export
add_rec_shade <- function(st_date, ed_date, shade_color = "darkgray") {
recession <- read.table(textConnection(
"date,value
1921-01-31,1
1921-02-28,1
1921-03-31,1
1921-04-30,1
1921-05-31,1
1921-06-30,1
1921-07-31,1
1921-08-31,0
1921-09-30,0
1921-10-31,0
1921-11-30,0
1921-12-31,0
1922-01-31,0
1922-02-28,0
1922-03-31,0
1922-04-30,0
1922-05-31,0
1922-06-30,0
1922-07-31,0
1922-08-31,0
1922-09-30,0
1922-10-31,0
1922-11-30,0
1922-12-31,0
1923-01-31,0
1923-02-28,0
1923-03-31,0
1923-04-30,0
1923-05-31,1
1923-06-30,1
1923-07-31,1
1923-08-31,1
1923-09-30,1
1923-10-31,1
1923-11-30,1
1923-12-31,1
1924-01-31,1
1924-02-29,1
1924-03-31,1
1924-04-30,1
1924-05-31,1
1924-06-30,1
1924-07-31,1
1924-08-31,0
1924-09-30,0
1924-10-31,0
1924-11-30,0
1924-12-31,0
1925-01-31,0
1925-02-28,0
1925-03-31,0
1925-04-30,0
1925-05-31,0
1925-06-30,0
1925-07-31,0
1925-08-31,0
1925-09-30,0
1925-10-31,0
1925-11-30,0
1925-12-31,0
1926-01-31,0
1926-02-28,0
1926-03-31,0
1926-04-30,0
1926-05-31,0
1926-06-30,0
1926-07-31,0
1926-08-31,0
1926-09-30,0
1926-10-31,1
1926-11-30,1
1926-12-31,1
1927-01-31,1
1927-02-28,1
1927-03-31,1
1927-04-30,1
1927-05-31,1
1927-06-30,1
1927-07-31,1
1927-08-31,1
1927-09-30,1
1927-10-31,1
1927-11-30,1
1927-12-31,0
1928-01-31,0
1928-02-29,0
1928-03-31,0
1928-04-30,0
1928-05-31,0
1928-06-30,0
1928-07-31,0
1928-08-31,0
1928-09-30,0
1928-10-31,0
1928-11-30,0
1928-12-31,0
1929-01-31,0
1929-02-28,0
1929-03-31,0
1929-04-30,0
1929-05-31,0
1929-06-30,0
1929-07-31,0
1929-08-31,1
1929-09-30,1
1929-10-31,1
1929-11-30,1
1929-12-31,1
1930-01-31,1
1930-02-28,1
1930-03-31,1
1930-04-30,1
1930-05-31,1
1930-06-30,1
1930-07-31,1
1930-08-31,1
1930-09-30,1
1930-10-31,1
1930-11-30,1
1930-12-31,1
1931-01-31,1
1931-02-28,1
1931-03-31,1
1931-04-30,1
1931-05-31,1
1931-06-30,1
1931-07-31,1
1931-08-31,1
1931-09-30,1
1931-10-31,1
1931-11-30,1
1931-12-31,1
1932-01-31,1
1932-02-29,1
1932-03-31,1
1932-04-30,1
1932-05-31,1
1932-06-30,1
1932-07-31,1
1932-08-31,1
1932-09-30,1
1932-10-31,1
1932-11-30,1
1932-12-31,1
1933-01-31,1
1933-02-28,1
1933-03-31,1
1933-04-30,0
1933-05-31,0
1933-06-30,0
1933-07-31,0
1933-08-31,0
1933-09-30,0
1933-10-31,0
1933-11-30,0
1933-12-31,0
1934-01-31,0
1934-02-28,0
1934-03-31,0
1934-04-30,0
1934-05-31,0
1934-06-30,0
1934-07-31,0
1934-08-31,0
1934-09-30,0
1934-10-31,0
1934-11-30,0
1934-12-31,0
1935-01-31,0
1935-02-28,0
1935-03-31,0
1935-04-30,0
1935-05-31,0
1935-06-30,0
1935-07-31,0
1935-08-31,0
1935-09-30,0
1935-10-31,0
1935-11-30,0
1935-12-31,0
1936-01-31,0
1936-02-29,0
1936-03-31,0
1936-04-30,0
1936-05-31,0
1936-06-30,0
1936-07-31,0
1936-08-31,0
1936-09-30,0
1936-10-31,0
1936-11-30,0
1936-12-31,0
1937-01-31,0
1937-02-28,0
1937-03-31,0
1937-04-30,0
1937-05-31,1
1937-06-30,1
1937-07-31,1
1937-08-31,1
1937-09-30,1
1937-10-31,1
1937-11-30,1
1937-12-31,1
1938-01-31,1
1938-02-28,1
1938-03-31,1
1938-04-30,1
1938-05-31,1
1938-06-30,1
1938-07-31,0
1938-08-31,0
1938-09-30,0
1938-10-31,0
1938-11-30,0
1938-12-31,0
1939-01-31,0
1939-02-28,0
1939-03-31,0
1939-04-30,0
1939-05-31,0
1939-06-30,0
1939-07-31,0
1939-08-31,0
1939-09-30,0
1939-10-31,0
1939-11-30,0
1939-12-31,0
1940-01-31,0
1940-02-29,0
1940-03-31,0
1940-04-30,0
1940-05-31,0
1940-06-30,0
1940-07-31,0
1940-08-31,0
1940-09-30,0
1940-10-31,0
1940-11-30,0
1940-12-31,0
1941-01-31,0
1941-02-28,0
1941-03-31,0
1941-04-30,0
1941-05-31,0
1941-06-30,0
1941-07-31,0
1941-08-31,0
1941-09-30,0
1941-10-31,0
1941-11-30,0
1941-12-31,0
1942-01-31,0
1942-02-28,0
1942-03-31,0
1942-04-30,0
1942-05-31,0
1942-06-30,0
1942-07-31,0
1942-08-31,0
1942-09-30,0
1942-10-31,0
1942-11-30,0
1942-12-31,0
1943-01-31,0
1943-02-28,0
1943-03-31,0
1943-04-30,0
1943-05-31,0
1943-06-30,0
1943-07-31,0
1943-08-31,0
1943-09-30,0
1943-10-31,0
1943-11-30,0
1943-12-31,0
1944-01-31,0
1944-02-29,0
1944-03-31,0
1944-04-30,0
1944-05-31,0
1944-06-30,0
1944-07-31,0
1944-08-31,0
1944-09-30,0
1944-10-31,0
1944-11-30,0
1944-12-31,0
1945-01-31,0
1945-02-28,1
1945-03-31,1
1945-04-30,1
1945-05-31,1
1945-06-30,1
1945-07-31,1
1945-08-31,1
1945-09-30,1
1945-10-31,1
1945-11-30,0
1945-12-31,0
1946-01-31,0
1946-02-28,0
1946-03-31,0
1946-04-30,0
1946-05-31,0
1946-06-30,0
1946-07-31,0
1946-08-31,0
1946-09-30,0
1946-10-31,0
1946-11-30,0
1946-12-31,0
1947-01-31,0
1947-02-28,0
1947-03-31,0
1947-04-30,0
1947-05-31,0
1947-06-30,0
1947-07-31,0
1947-08-31,0
1947-09-30,0
1947-10-31,0
1947-11-30,0
1947-12-31,0
1948-01-31,0
1948-02-29,0
1948-03-31,0
1948-04-30,0
1948-05-31,0
1948-06-30,0
1948-07-31,0
1948-08-31,0
1948-09-30,0
1948-10-31,0
1948-11-30,1
1948-12-31,1
1949-01-31,1
1949-02-28,1
1949-03-31,1
1949-04-30,1
1949-05-31,1
1949-06-30,1
1949-07-31,1
1949-08-31,1
1949-09-30,1
1949-10-31,1
1949-11-30,0
1949-12-31,0
1950-01-31,0
1950-02-28,0
1950-03-31,0
1950-04-30,0
1950-05-31,0
1950-06-30,0
1950-07-31,0
1950-08-31,0
1950-09-30,0
1950-10-31,0
1950-11-30,0
1950-12-31,0
1951-01-31,0
1951-02-28,0
1951-03-31,0
1951-04-30,0
1951-05-31,0
1951-06-30,0
1951-07-31,0
1951-08-31,0
1951-09-30,0
1951-10-31,0
1951-11-30,0
1951-12-31,0
1952-01-31,0
1952-02-29,0
1952-03-31,0
1952-04-30,0
1952-05-31,0
1952-06-30,0
1952-07-31,0
1952-08-31,0
1952-09-30,0
1952-10-31,0
1952-11-30,0
1952-12-31,0
1953-01-31,0
1953-02-28,0
1953-03-31,0
1953-04-30,0
1953-05-31,0
1953-06-30,0
1953-07-31,1
1953-08-31,1
1953-09-30,1
1953-10-31,1
1953-11-30,1
1953-12-31,1
1954-01-31,1
1954-02-28,1
1954-03-31,1
1954-04-30,1
1954-05-31,1
1954-06-30,0
1954-07-31,0
1954-08-31,0
1954-09-30,0
1954-10-31,0
1954-11-30,0
1954-12-31,0
1955-01-31,0
1955-02-28,0
1955-03-31,0
1955-04-30,0
1955-05-31,0
1955-06-30,0
1955-07-31,0
1955-08-31,0
1955-09-30,0
1955-10-31,0
1955-11-30,0
1955-12-31,0
1956-01-31,0
1956-02-29,0
1956-03-31,0
1956-04-30,0
1956-05-31,0
1956-06-30,0
1956-07-31,0
1956-08-31,0
1956-09-30,0
1956-10-31,0
1956-11-30,0
1956-12-31,0
1957-01-31,0
1957-02-28,0
1957-03-31,0
1957-04-30,0
1957-05-31,0
1957-06-30,0
1957-07-31,0
1957-08-31,1
1957-09-30,1
1957-10-31,1
1957-11-30,1
1957-12-31,1
1958-01-31,1
1958-02-28,1
1958-03-31,1
1958-04-30,1
1958-05-31,0
1958-06-30,0
1958-07-31,0
1958-08-31,0
1958-09-30,0
1958-10-31,0
1958-11-30,0
1958-12-31,0
1959-01-31,0
1959-02-28,0
1959-03-31,0
1959-04-30,0
1959-05-31,0
1959-06-30,0
1959-07-31,0
1959-08-31,0
1959-09-30,0
1959-10-31,0
1959-11-30,0
1959-12-31,0
1960-01-31,0
1960-02-29,0
1960-03-31,0
1960-04-30,1
1960-05-31,1
1960-06-30,1
1960-07-31,1
1960-08-31,1
1960-09-30,1
1960-10-31,1
1960-11-30,1
1960-12-31,1
1961-01-31,1
1961-02-28,1
1961-03-31,0
1961-04-30,0
1961-05-31,0
1961-06-30,0
1961-07-31,0
1961-08-31,0
1961-09-30,0
1961-10-31,0
1961-11-30,0
1961-12-31,0
1962-01-31,0
1962-02-28,0
1962-03-31,0
1962-04-30,0
1962-05-31,0
1962-06-30,0
1962-07-31,0
1962-08-31,0
1962-09-30,0
1962-10-31,0
1962-11-30,0
1962-12-31,0
1963-01-31,0
1963-02-28,0
1963-03-31,0
1963-04-30,0
1963-05-31,0
1963-06-30,0
1963-07-31,0
1963-08-31,0
1963-09-30,0
1963-10-31,0
1963-11-30,0
1963-12-31,0
1964-01-31,0
1964-02-29,0
1964-03-31,0
1964-04-30,0
1964-05-31,0
1964-06-30,0
1964-07-31,0
1964-08-31,0
1964-09-30,0
1964-10-31,0
1964-11-30,0
1964-12-31,0
1965-01-31,0
1965-02-28,0
1965-03-31,0
1965-04-30,0
1965-05-31,0
1965-06-30,0
1965-07-31,0
1965-08-31,0
1965-09-30,0
1965-10-31,0
1965-11-30,0
1965-12-31,0
1966-01-31,0
1966-02-28,0
1966-03-31,0
1966-04-30,0
1966-05-31,0
1966-06-30,0
1966-07-31,0
1966-08-31,0
1966-09-30,0
1966-10-31,0
1966-11-30,0
1966-12-31,0
1967-01-31,0
1967-02-28,0
1967-03-31,0
1967-04-30,0
1967-05-31,0
1967-06-30,0
1967-07-31,0
1967-08-31,0
1967-09-30,0
1967-10-31,0
1967-11-30,0
1967-12-31,0
1968-01-31,0
1968-02-29,0
1968-03-31,0
1968-04-30,0
1968-05-31,0
1968-06-30,0
1968-07-31,0
1968-08-31,0
1968-09-30,0
1968-10-31,0
1968-11-30,0
1968-12-31,0
1969-01-31,0
1969-02-28,0
1969-03-31,0
1969-04-30,0
1969-05-31,0
1969-06-30,0
1969-07-31,0
1969-08-31,0
1969-09-30,0
1969-10-31,0
1969-11-30,0
1969-12-31,1
1970-01-31,1
1970-02-28,1
1970-03-31,1
1970-04-30,1
1970-05-31,1
1970-06-30,1
1970-07-31,1
1970-08-31,1
1970-09-30,1
1970-10-31,1
1970-11-30,1
1970-12-31,0
1971-01-31,0
1971-02-28,0
1971-03-31,0
1971-04-30,0
1971-05-31,0
1971-06-30,0
1971-07-31,0
1971-08-31,0
1971-09-30,0
1971-10-31,0
1971-11-30,0
1971-12-31,0
1972-01-31,0
1972-02-29,0
1972-03-31,0
1972-04-30,0
1972-05-31,0
1972-06-30,0
1972-07-31,0
1972-08-31,0
1972-09-30,0
1972-10-31,0
1972-11-30,0
1972-12-31,0
1973-01-31,0
1973-02-28,0
1973-03-31,0
1973-04-30,0
1973-05-31,0
1973-06-30,0
1973-07-31,0
1973-08-31,0
1973-09-30,0
1973-10-31,0
1973-11-30,1
1973-12-31,1
1974-01-31,1
1974-02-28,1
1974-03-31,1
1974-04-30,1
1974-05-31,1
1974-06-30,1
1974-07-31,1
1974-08-31,1
1974-09-30,1
1974-10-31,1
1974-11-30,1
1974-12-31,1
1975-01-31,1
1975-02-28,1
1975-03-31,1
1975-04-30,0
1975-05-31,0
1975-06-30,0
1975-07-31,0
1975-08-31,0
1975-09-30,0
1975-10-31,0
1975-11-30,0
1975-12-31,0
1976-01-31,0
1976-02-29,0
1976-03-31,0
1976-04-30,0
1976-05-31,0
1976-06-30,0
1976-07-31,0
1976-08-31,0
1976-09-30,0
1976-10-31,0
1976-11-30,0
1976-12-31,0
1977-01-31,0
1977-02-28,0
1977-03-31,0
1977-04-30,0
1977-05-31,0
1977-06-30,0
1977-07-31,0
1977-08-31,0
1977-09-30,0
1977-10-31,0
1977-11-30,0
1977-12-31,0
1978-01-31,0
1978-02-28,0
1978-03-31,0
1978-04-30,0
1978-05-31,0
1978-06-30,0
1978-07-31,0
1978-08-31,0
1978-09-30,0
1978-10-31,0
1978-11-30,0
1978-12-31,0
1979-01-31,0
1979-02-28,0
1979-03-31,0
1979-04-30,0
1979-05-31,0
1979-06-30,0
1979-07-31,0
1979-08-31,0
1979-09-30,0
1979-10-31,0
1979-11-30,0
1979-12-31,0
1980-01-31,1
1980-02-29,1
1980-03-31,1
1980-04-30,1
1980-05-31,1
1980-06-30,1
1980-07-31,1
1980-08-31,0
1980-09-30,0
1980-10-31,0
1980-11-30,0
1980-12-31,0
1981-01-31,0
1981-02-28,0
1981-03-31,0
1981-04-30,0
1981-05-31,0
1981-06-30,0
1981-07-31,1
1981-08-31,1
1981-09-30,1
1981-10-31,1
1981-11-30,1
1981-12-31,1
1982-01-31,1
1982-02-28,1
1982-03-31,1
1982-04-30,1
1982-05-31,1
1982-06-30,1
1982-07-31,1
1982-08-31,1
1982-09-30,1
1982-10-31,1
1982-11-30,1
1982-12-31,0
1983-01-31,0
1983-02-28,0
1983-03-31,0
1983-04-30,0
1983-05-31,0
1983-06-30,0
1983-07-31,0
1983-08-31,0
1983-09-30,0
1983-10-31,0
1983-11-30,0
1983-12-31,0
1984-01-31,0
1984-02-29,0
1984-03-31,0
1984-04-30,0
1984-05-31,0
1984-06-30,0
1984-07-31,0
1984-08-31,0
1984-09-30,0
1984-10-31,0
1984-11-30,0
1984-12-31,0
1985-01-31,0
1985-02-28,0
1985-03-31,0
1985-04-30,0
1985-05-31,0
1985-06-30,0
1985-07-31,0
1985-08-31,0
1985-09-30,0
1985-10-31,0
1985-11-30,0
1985-12-31,0
1986-01-31,0
1986-02-28,0
1986-03-31,0
1986-04-30,0
1986-05-31,0
1986-06-30,0
1986-07-31,0
1986-08-31,0
1986-09-30,0
1986-10-31,0
1986-11-30,0
1986-12-31,0
1987-01-31,0
1987-02-28,0
1987-03-31,0
1987-04-30,0
1987-05-31,0
1987-06-30,0
1987-07-31,0
1987-08-31,0
1987-09-30,0
1987-10-31,0
1987-11-30,0
1987-12-31,0
1988-01-31,0
1988-02-29,0
1988-03-31,0
1988-04-30,0
1988-05-31,0
1988-06-30,0
1988-07-31,0
1988-08-31,0
1988-09-30,0
1988-10-31,0
1988-11-30,0
1988-12-31,0
1989-01-31,0
1989-02-28,0
1989-03-31,0
1989-04-30,0
1989-05-31,0
1989-06-30,0
1989-07-31,0
1989-08-31,0
1989-09-30,0
1989-10-31,0
1989-11-30,0
1989-12-31,0
1990-01-31,0
1990-02-28,0
1990-03-31,0
1990-04-30,0
1990-05-31,0
1990-06-30,0
1990-07-31,1
1990-08-31,1
1990-09-30,1
1990-10-31,1
1990-11-30,1
1990-12-31,1
1991-01-31,1
1991-02-28,1
1991-03-31,1
1991-04-30,0
1991-05-31,0
1991-06-30,0
1991-07-31,0
1991-08-31,0
1991-09-30,0
1991-10-31,0
1991-11-30,0
1991-12-31,0
1992-01-31,0
1992-02-29,0
1992-03-31,0
1992-04-30,0
1992-05-31,0
1992-06-30,0
1992-07-31,0
1992-08-31,0
1992-09-30,0
1992-10-31,0
1992-11-30,0
1992-12-31,0
1993-01-31,0
1993-02-28,0
1993-03-31,0
1993-04-30,0
1993-05-31,0
1993-06-30,0
1993-07-31,0
1993-08-31,0
1993-09-30,0
1993-10-31,0
1993-11-30,0
1993-12-31,0
1994-01-31,0
1994-02-28,0
1994-03-31,0
1994-04-30,0
1994-05-31,0
1994-06-30,0
1994-07-31,0
1994-08-31,0
1994-09-30,0
1994-10-31,0
1994-11-30,0
1994-12-31,0
1995-01-31,0
1995-02-28,0
1995-03-31,0
1995-04-30,0
1995-05-31,0
1995-06-30,0
1995-07-31,0
1995-08-31,0
1995-09-30,0
1995-10-31,0
1995-11-30,0
1995-12-31,0
1996-01-31,0
1996-02-29,0
1996-03-31,0
1996-04-30,0
1996-05-31,0
1996-06-30,0
1996-07-31,0
1996-08-31,0
1996-09-30,0
1996-10-31,0
1996-11-30,0
1996-12-31,0
1997-01-31,0
1997-02-28,0
1997-03-31,0
1997-04-30,0
1997-05-31,0
1997-06-30,0
1997-07-31,0
1997-08-31,0
1997-09-30,0
1997-10-31,0
1997-11-30,0
1997-12-31,0
1998-01-31,0
1998-02-28,0
1998-03-31,0
1998-04-30,0
1998-05-31,0
1998-06-30,0
1998-07-31,0
1998-08-31,0
1998-09-30,0
1998-10-31,0
1998-11-30,0
1998-12-31,0
1999-01-31,0
1999-02-28,0
1999-03-31,0
1999-04-30,0
1999-05-31,0
1999-06-30,0
1999-07-31,0
1999-08-31,0
1999-09-30,0
1999-10-31,0
1999-11-30,0
1999-12-31,0
2000-01-31,0
2000-02-29,0
2000-03-31,0
2000-04-30,0
2000-05-31,0
2000-06-30,0
2000-07-31,0
2000-08-31,0
2000-09-30,0
2000-10-31,0
2000-11-30,0
2000-12-31,0
2001-01-31,0
2001-02-28,0
2001-03-31,1
2001-04-30,1
2001-05-31,1
2001-06-30,1
2001-07-31,1
2001-08-31,1
2001-09-30,1
2001-10-31,1
2001-11-30,1
2001-12-31,0
2002-01-31,0
2002-02-28,0
2002-03-31,0
2002-04-30,0
2002-05-31,0
2002-06-30,0
2002-07-31,0
2002-08-31,0
2002-09-30,0
2002-10-31,0
2002-11-30,0
2002-12-31,0
2003-01-31,0
2003-02-28,0
2003-03-31,0
2003-04-30,0
2003-05-31,0
2003-06-30,0
2003-07-31,0
2003-08-31,0
2003-09-30,0
2003-10-31,0
2003-11-30,0
2003-12-31,0
2004-01-31,0
2004-02-29,0
2004-03-31,0
2004-04-30,0
2004-05-31,0
2004-06-30,0
2004-07-31,0
2004-08-31,0
2004-09-30,0
2004-10-31,0
2004-11-30,0
2004-12-31,0
2005-01-31,0
2005-02-28,0
2005-03-31,0
2005-04-30,0
2005-05-31,0
2005-06-30,0
2005-07-31,0
2005-08-31,0
2005-09-30,0
2005-10-31,0
2005-11-30,0
2005-12-31,0
2006-01-31,0
2006-02-28,0
2006-03-31,0
2006-04-30,0
2006-05-31,0
2006-06-30,0
2006-07-31,0
2006-08-31,0
2006-09-30,0
2006-10-31,0
2006-11-30,0
2006-12-31,0
2007-01-31,0
2007-02-28,0
2007-03-31,0
2007-04-30,0
2007-05-31,0
2007-06-30,0
2007-07-31,0
2007-08-31,0
2007-09-30,0
2007-10-31,0
2007-11-30,0
2007-12-31,1
2008-01-31,1
2008-02-29,1
2008-03-31,1
2008-04-30,1
2008-05-31,1
2008-06-30,1
2008-07-31,1
2008-08-31,1
2008-09-30,1
2008-10-31,1
2008-11-30,1
2008-12-31,1
2009-01-31,1
2009-02-28,1
2009-03-31,1
2009-04-30,1
2009-05-31,1
2009-06-30,1
2009-07-31,0
2009-08-31,0
2009-09-30,0
2009-10-31,0
2009-11-30,0
2009-12-31,0
2010-01-31,0
2010-02-28,0
2010-03-31,0
2010-04-30,0
2010-05-31,0
2010-06-30,0
2010-07-31,0
2010-08-31,0
2010-09-30,0
2010-10-31,0
2010-11-30,0
2010-12-31,0
2011-01-31,0
2011-02-28,0
2011-03-31,0
2011-04-30,0
2011-05-31,0
2011-06-30,0
2011-07-31,0
2011-08-31,0
2011-09-30,0
2011-10-31,0
2011-11-30,0
2011-12-31,0
2012-01-31,0
2012-02-29,0
2012-03-31,0
2012-04-30,0
2012-05-31,0
2012-06-30,0
2012-07-31,0
2012-08-31,0
2012-09-30,0
2012-10-31,0
2012-11-30,0
2012-12-31,0
2013-01-31,0
2013-02-28,0
2013-03-31,0
2013-04-30,0
2013-05-31,0
2013-06-30,0
2013-07-31,0
2013-08-31,0
2013-09-30,0
2013-10-31,0
2013-11-30,0
2013-12-31,0
2014-01-31,0
2014-02-28,0
2014-03-31,0
2014-04-30,0
2014-05-31,0
2014-06-30,0
2014-07-31,0
2014-08-31,0
2014-09-30,0
2014-10-31,0
2014-11-30,0
2014-12-31,0
2015-01-31,0
2015-02-28,0
2015-03-31,0
2015-04-30,0
2015-05-31,0
2015-06-30,0
2015-07-31,0
2015-08-31,0
2015-09-30,0
2015-10-31,0
2015-11-30,0
2015-12-31,0
2016-01-31,0
2016-02-29,0
2016-03-31,0
2016-04-30,0
2016-05-31,0
2016-06-30,0
2016-07-31,0
2016-08-31,0
2016-09-30,0
2016-10-31,0
2016-11-30,0
2016-12-31,0
2017-01-31,0
2017-02-28,0
2017-03-31,0
2017-04-30,0
2017-05-31,0
2017-06-30,0
2017-07-31,0
2017-08-31,0
2017-09-30,0
2017-10-31,0
2017-11-30,0
2017-12-31,0
2018-01-31,0
2018-02-28,0
2018-03-31,0
2018-04-30,0
2018-05-31,0
2018-06-30,0
2018-07-31,0
2018-08-31,0
2018-09-30,0
2018-10-31,0
2018-11-30,0
2018-12-31,0
2019-01-31,0
2019-02-28,0
2019-03-31,0
2019-04-30,0
2019-05-31,0
2019-06-30,0
2019-07-31,0
2019-08-31,0
2019-09-30,0
2019-10-31,0
2019-11-30,0
2019-12-31,0
2020-01-31,0
2020-02-29,1
2020-03-31,1
2020-04-30,1
2020-05-31,0
2020-06-30,0
2020-07-31,0
2020-08-31,0
2020-09-30,0
2020-10-31,0
2020-11-30,0
2020-12-31,0
2021-01-31,0
2021-02-28,0
2021-03-31,0
2021-04-30,0
2021-05-31,0
2021-06-30,0
2021-07-31,0
2021-08-31,0
"), sep=',',
colClasses=c('Date', 'numeric'), header=TRUE)
recession <- dplyr::filter(recession, date >= st_date & date <= ed_date)
recession$diff <- recession$value - ecm::lagpad(recession$value, k = 1)
recession <- recession[!is.na(recession$diff), ]
recession.start <- recession[recession$diff == 1, ]$date
recession.end <- recession[recession$diff == (-1), ]$date
if (length(recession.start) > length(recession.end)) {
recession.end <- c(recession.end, Sys.Date())
}
if (length(recession.end) > length(recession.start)) {
recession.start <- c(min(recession$date), recession.start)
}
recs <- as.data.frame(cbind(recession.start, recession.end))
recs$recession.start <- as.Date(as.numeric(recs$recession.start), origin = as.Date("1970-01-01"))
recs$recession.end <- as.Date(recs$recession.end, origin = as.Date("1970-01-01"))
if (nrow(recs) > 0) {
rec_shade <- ggplot2::geom_rect(
data = recs,
inherit.aes = FALSE,
aes(xmin = recession.start, xmax = recession.end, ymin = -Inf, ymax = +Inf),
fill = shade_color,
alpha = 0.5
)
return(rec_shade)
}
}
#' CSM Green
#'
#' This function that calls CSM's green color
#' @return A string of the CSM green hexcode
#' @export
csm_green <- function() rgb(0, 102, 52, maxColorValue = 255)
#' CSM Gray
#'
#' This function that calls CSM's gray color
#' @return A string of the CSM gray hexcode
#' @export
csm_gray <- function() rgb(242, 242, 242, maxColorValue = 255)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.