I wrote the ggplot below and have several ggplot's that are similar to this one in my code. For some reason, the code runs and produces the wanted output, although will not knit to a pdf and states the following error. Do you know how to fix this so I can knit my rmarkdown.
colors<-c("Corn"="goldenrod2", "Wheat"="wheat3", "Soybean"="orange3")
Commodity.Series <- Commodity_prices %>%
ggplot(aes(x=Date)) +
geom_line(aes(y=Corn.Price, color="Corn")) +
geom_line(aes(y=Wheat.Price, color="Wheat")) +
geom_line(aes(y=Soybean.Price, color="Soybean")) +
scale_color_manual(values = colors) +
scale_x_date(date_labels = "%b-%y", date_breaks = "3 years", ) +
labs(title="3 Main US Agricultural Grain Commodities",
subtitle ="Price per bushel, Dec 1968 - Aug 2022", y="Commodity Prices (USD $)",
color="Commodities", caption = "Price Data Source: Macrotrend.net") +
ylim(0,17) + theme_ipsum() +
theme(axis.text.x = element_text(angle = 45)) +
annotate("rect", fill = "pink", alpha = 0.5,xmin = US.recession.df$start, xmax = US.recession.df$end,
min = -Inf, ymax = Inf)+
annotate("text", y = 15, x = as.Date("1978-01-06"), label="Highlighted US Recessions", size=2.5)
Commodity.Series