问题
I am working in R Markdown, knitting to PDF.
I thought the following code should create a table with a local image, but it is not working. Any help would be greatly appreciated!
column1 <- c("1", "2", "3")
column2 <- c("a", "b", "c")
column3 <- c("x", "y", "z")
dat <- data.frame(column1, column2, column3)
dat$column1[1] <- "![image1](green.png){ width=25px }"
print(kable(dat))
回答1:
---
title: "pic in column"
author: "test"
date: "2014/08/03"
output: html_document
---
```{r results='asis'}
library(knitr)
column1 <- c("1", "2", "3")
column2 <- c("a", "b", "c")
column3 <- c("x", "y", "z")
dat <- data.frame(column1, column2, column3)
dat$column1<- sprintf('![](green.png)')
print(kable(dat))
```
I just used the link in the comments and fit your question into the code. if you wanted different pictures for each row, you maybe need to save the file names into a vector. In the example you could also use images from a webpage
来源:https://stackoverflow.com/questions/63239214/including-an-image-in-r-markdown-pdf-table