简体   繁体   中英

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

在此处输入图片说明

Plot of the data that won't knit but other chunks do knit在此处输入图片说明

找到解决方案:我只是将它保存到一个新的 RMarkdown 文档中,似乎在我更改某些代码时由于某些不匹配或命名错误而导致编织出现问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM