使用图像作为RMarkdown中的表格? [英] Use image as table in RMarkdown?

查看:110
本文介绍了使用图像作为RMarkdown中的表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很高兴我尝试做的事情听起来很愚蠢,但请多多包涵.我想将表格的现有图像(PNG)插入RMarkdown文档中,该文档将转换为pdf.有什么办法可以我将图像视为表格以进行编号?也就是说,很明显我可以做到

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)

,但问题是它将被编号为图X,而不是表Y.我希望将其命名/编号为表.

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.

谢谢您的任何建议.

推荐答案

好像我找到了一种使用kable做到这一点的方法-an-image-to-a-table-like-output-in-r>一些

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")

```

这篇关于使用图像作为RMarkdown中的表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆