Use image as table in RMarkdown?

情到浓时终转凉″ 提交于 2019-12-11 10:42:04

问题


I appreciate that what I'm trying to do will sound silly, but please bear with me. I want to insert an existing image (a PNG) of a table into an RMarkdown document that will be turned into a pdf. Is there any way I can do this and have the image treated as a table for numbering purposes? That is, obviously I could do

![A caption for my table](my_table_as_image.png)

but the problem is that it will be numbered as e.g. Figure X, not Table Y. I would like it to be named/numbered as a table.

Thank you for any advice.


回答1:


Looks like I got to a way to do it with kable with some inspiration...this still has two horizontal lines but that's ok for the moment:

```{r echo=F, warning=F}
temp.df = data.frame(image="![](mytable.png)")
temp.mat <- as.matrix(temp.df)
colnames(temp.mat) <- NULL
knitr::kable(temp.mat, caption="This is my caption")

```


来源:https://stackoverflow.com/questions/55523128/use-image-as-table-in-rmarkdown

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!