【发布时间】:2017-11-06 23:12:00
【问题描述】:
---
title: "Untitled"
runtime: shiny
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
df <- data.frame(image = "http://www.ufotm.com/data/attachment/forum/201203/11/110705gf50r55yqcka5ffz.jpg", title = "here is a title")
DT::renderDataTable(df,
escape = FALSE,
rownames = FALSE,
extensions = 'Buttons', options = list(
dom = 'lBfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print')
)
)
```
我有图片网址。我尝试在 rmarkdown 或闪亮的应用程序中插入图像。我更喜欢DT 库,因为那时我可以下载 excel 文件。我该怎么做?
PS:我也想提供 excel 或 pdf 文件供我的用户下载。
我尝试使用DataTables Options,并找到related question。我尝试了下面的代码,它显示错误。
---
title: "Untitled"
runtime: shiny
output: html_document
---
df <- data.frame(image = "http://www.ufotm.com/data/attachment/forum/201203/11/110705gf50r55yqcka5ffz.jpg", title = "here is a title")
DT::renderDataTable(df,
escape = FALSE,
rownames = FALSE,
extensions = 'Buttons', options = list(
dom = 'lBfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
columnDefs = list(list(targets = 1,
data = "img",
render = JS(
'function ( url, type, full) {',
'return '<img height="75%" width="75%" src="'+full[7]+'"/>';',
'}'
)
))
)
)
【问题讨论】:
标签: r shiny r-markdown dt