I'm trying to build a custom ggplot theme in R, but when I try to use the plot I get the error in the header.
The code is such:
test <- ggplot(pop_annual_12000, mapping=aes(x=year, y=WorldPop)) + geom_smooth() + light_theme()
Here's the code used to build the theme:
light_theme <- function(){theme(
axis.title = element_text(family=font_add_google("Source Sans Pro"), colour = "#242e3c"),
axis.text = element_text(family=font_add_google("Source Sans Pro"), colour = "#242e3c"),
axis.ticks.x = element_line(colour="#e8e8e8"),
axis.ticks.y = element_line(linetype="blank"),
axis.line.x = element_line(linetype="blank"),
axis.line.y = element_line(linetype="blank"),
legend.text = element_text(family=font_add_google("Source Sans Pro")),
panel.border = element_rect(linetype="blank"),
panel.grid = element_rect(colour="#e8e8e8", linetype = "dashed"),
plot.title = element_text(family=font_add_google("Playfair Display"), colour= "#242e3c"))}
Not sure what I'm doing that's causing the error.
Edit:
The non-base R packages used were RColorBrewer, sysfonts, and tidyverse. The input would just be a data frame (similar to the pre-loaded dataframes like diamond or nycflights13), and the output I'm expecting is just a ggplot that implements my theme.