Weekday Output not Showing up on Bar chart when I use Knit function in R Markdown

34 Views Asked by At

I am practicing working with dates in R, and I stumbled across a problem. I wanted to convert dates into their actual day of the week, so I could conduct a bar chart and other graphs. The graph shows up correctly on R markdown before I use the Knit function. After hitting the knit function, the bar chart shows up, but the days are NA's.

enter image description here

Attempt:

library(dplyr)
library(ggplot2)
PizzaData2$order_date <- as.Date(PizzaData2$order_date, format = "%Y-%m-%d")
PizzaData3 <- PizzaData2 %>%
  mutate( week_day = wday(order_date, label = TRUE, week_start = 1, abbr = FALSE))
ggplot(data = PizzaData3)+
  geom_bar(mapping = aes(x = week_day, fill = week_day))

This is how it looks after the R Markdown: enter image description here

Can someone explain why the graph isn't showing correctly?

0

There are 0 best solutions below