0

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

enter image description here enter image description here

https://rpubs.com/mfilgiano/932057

Matt2815
  • 1
  • 1
  • 1
    It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Aug 12 '22 at 17:25
  • What do you see when you enter `warnings()` into the console? This error is from the call `theme_ipsum()`. I don't have Windows; I don't have `Arial Narrow`. I have the alternative—Roboto Condensed. Try setting a specific font in the call, i.e., `theme_ipsum(base_family = "Roboto Condensed")`. (It may not be the font. I would expect to see `font family...` in the error.) Check the other parameters in `theme_ipsum` setting family doesn't help. Do your other graphs use this theme? You could also try the pkg `showtext` to get a new font (if the font is the issue). – Kat Aug 13 '22 at 02:01

0 Answers0