Insert images using knitr::include_graphics in a for loop

后端 未结 2 2034
梦如初夏
梦如初夏 2020-12-03 11:44
```{r}
knitr::include_graphics(path = \"~/Desktop/R/Files/apple.jpg/\")
```

The above code chunk works fine. However, when I create a for

2条回答
  •  [愿得一人]
    2020-12-03 12:42

    include_graphics() has to be used in top-level R expressions as Yihui stated here

    My workaround is this:

    ```{r out.width = "90%", echo=FALSE, fig.align='center'}
    files <- list.files(path = paste0('../', myImgPath), 
                        pattern = "^IMG(.*).jpg$",
                        full.names = TRUE)
    
    knitr::include_graphics(files)
    
    ```
    

提交回复
热议问题