1

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

Jaskeil
  • 1,044
  • 12
  • 33
  • It's easier to help you if you include a simple [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. Are you using `save()`/`load()` anywhere? What version of R are you running? – MrFlick Oct 06 '20 at 23:21
  • I am using R 3.6.3. I am not using save() or load() anywhere. I will update the question with screenshot of my data – Jaskeil Oct 06 '20 at 23:24
  • Showing us the code that loads your data might be more useful. – user2554330 Oct 06 '20 at 23:31
  • It's an 11 million row table from Google BigQuery. I aggregate using the dplyr verbs that you see in step1_cnt_2019bar & step1_cnt_2020bar. The final output table is the binded_table – Jaskeil Oct 06 '20 at 23:34

1 Answers1

1

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

Jaskeil
  • 1,044
  • 12
  • 33