Hi

knitr::opts_chunk$set(echo = TRUE,
                      message = FALSE, 
                      warning = FALSE)

Install

devtools::install_github("einarhjorleifsson/ggmisc")

Libraries

library(ggmisc)
library(tidyverse)

scale_fill_crayola (only function so far)

read_csv("http://data.hafro.is/assmt/2018/cod/smb.csv") %>% 
  gather(key = age, value = oU, -Year, convert = TRUE) %>% 
  rename(year = Year) %>% 
  mutate(yc = year - age) %>% 
  ggplot() +
  geom_col(aes(year, oU, fill = factor(yc))) + 
  scale_fill_crayola() +
  facet_grid(age ~ ., scale = "free_y") +
  theme(legend.position = "none") +
  scale_y_continuous(NULL, NULL) +
  scale_x_continuous(NULL, breaks = seq(1985, 2015, by = 5)) +
  labs(title = "It is the year class, stupid",
       subtitle = "The signal in the data is not age, not year, but yearclass")


einarhjorleifsson/ggmisc documentation built on Oct. 14, 2023, 11:45 p.m.