在R Markdown PDF表中包含图像 [英] Including an image in R Markdown PDF table

查看:70
本文介绍了在R Markdown PDF表中包含图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在R Markdown中工作,编织成PDF.

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

推荐答案

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

这篇关于在R Markdown PDF表中包含图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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