---
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')
)
)
```
I have the image url. I try to insert image in a rmarkdown or shiny app. I prefer DT
library because I can download excel file then. How can I do that?
PS: I want to provide excel or pdf file for my user to download as well.
I try to use DataTables Options, and find a related question. I tried the below code and it shows error.
---
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]+'"/>';',
'}'
)
))
)
)