Log Artefacts - log

Data - Fred

variable

Code
log %>%
  left_join(variable,  by = "variable") %>%
  group_by(variable, Variable) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

Chart Crime 1

Linear

Code
plot_linear <- log %>%
  filter(date >= as.Date("1996-05-01"),
         variable %in% c("HPIPONM226S", "AHETPI")) %>%
  left_join(variable, by = "variable") %>%
  group_by(Variable) %>%
  mutate(value = 100*value/value[1]) %>%
  ggplot(.) + theme_minimal() + xlab("") + ylab("") +
  geom_line(aes(x = date, y = value, color = Variable)) + 
  theme(legend.position = c(0.4, 0.90),
        legend.title = element_blank()) + 
  scale_x_date(breaks = seq(1700, 2025, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) + 
  scale_y_continuous(breaks = seq(100, 400, 50))

plot_linear

Log

Code
plot_log <- plot_linear + 
  scale_y_log10(breaks = seq(100, 400, 50))

plot_log

Bin

Code
ggpubr::ggarrange(plot_linear + ggtitle("Linear scale"), plot_log + ggtitle("Log scale"), common.legend = T)