Jaskeil
Jaskeil

Reputation: 1232

RMarkdown Error for knitting to HTML document? [code included]

I keep getting this error when I try to knit this chunk to HTML. If I set eval = FALSE then my plot does not show. Here is the error and code. Why is it that RMarkdown is either giving me this error or I cant knit my plot. I have another chunk that works perfectly fine and is displayed when knitted Error

 Quitting from lines 295-326 (RMarkDown_BVR_Model.Rmd) 
    Error in eval(lhs, parent, parent) : 
      ReadItem: unknown type 41, perhaps written by later version of R
    Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> %>% -> eval -> eval
    
    Execution halted 

Script

```{r 2020 v 2019 Orders, echo=FALSE, fig.height=6, fig.width=12, message=FALSE}

step1_cnt_2019bar <- step1_df %>% 
  group_by(CHANNEL) %>% 
  filter(DELV_FSCL_YR_WK >= 201901, DELV_FSCL_YR_WK <= 201953) %>% 
  summarise(Orders = n_distinct(ORD_TRACK_KEY), .groups ='drop', Year = '2019')


step1_cnt_2020bar <- step1_df %>% 
  group_by(CHANNEL) %>% 
  filter(DELV_FSCL_YR_WK >= 202001) %>% 
  summarise(Orders = n_distinct(ORD_TRACK_KEY), .groups ='drop', Year = '2020')



binded_table <-  union_all(step1_cnt_2020bar, step1_cnt_2019bar)


plot <- ggplot(binded_table, aes(x = Year, y = Orders, fill =  CHANNEL))+
geom_text(aes(label = Orders), vjust = -2.50)+
  geom_col(color="grey17", width = 0.25)+
  theme_economist()+
  xlab("Fiscal Year") +
  ylab("Count of Orders") +
    scale_fill_manual(values=c("slategray", "cornsilk", "snow4", "sandybrown"))+
   theme(plot.title = element_text(size=12), axis.text=element_text(size=10), 
        axis.title=element_text(size=10), strip.text = element_text(size=10),
        axis.title.y = element_text(margin = margin(t = 0, r = 20, b = 0, l = 0)),
        axis.title.x = element_text(margin = margin(t = 20, r = 20, b = 0, l = 0)))

plot

```

Data I am trying to plot and knit to HTML

enter image description here

Plot of the data that won't knit but other chunks do knit enter image description here

Upvotes: 1

Views: 480

Answers (1)

Jaskeil
Jaskeil

Reputation: 1232

Found the solution: I simply saved it to a new RMarkdown document, seems that there was an issue in knitting due to some mismatching or misnaming when I changed up some code

Upvotes: 1

Related Questions