R

Plotting in R

Do people care more about inflation or unemployment? Here’s R code to reproduce a plot featured by Professor Justin Wolfers in this tweet. library(ggplot2) library(gtrendsR) library(ggrepel) library(tidyverse) library(lubridate) dat <- gtrends(c("inflation", "unemployment"), geo = c("US")) interest <- as_tibble(dat$interest_over_time) interest <- interest %>% rename(date_time = date) %>% mutate(date = as_date(date_time, tz = NULL), my_label = case_when( date == ymd("2020-03-29") ~ keyword, TRUE ~ "" )) ggplot(data = interest) + geom_line(mapping = aes(x = date, y = hits, color = keyword), size = 0.