4
---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
library(DT)
xsx = function(){
  print(getOption("viewer"))
  print(datatable(data.frame(d =1)))
  1
}
xsx()
```

Inside xsx() function, DT widgets will not be rendered in HTML result. How can I get widgets print inside a function?

user3809734
  • 193
  • 7
  • `htmltools::html_print()`? – hrbrmstr Feb 23 '16 at 03:31
  • 2
    The short answer is you cannot. A slightly longer answer: your best bet is to put everything in a list and use `htmltools::tagList()`; see this post for an example: http://stackoverflow.com/q/30509866/559676 That may not be exactly what you want, but you cannot really mix arbitrary content with HTML widgets during printing. – Yihui Xie Feb 23 '16 at 05:25
  • @Yihui Thanks, `htmltools::tagList()` helps. – user3809734 Feb 23 '16 at 09:40

0 Answers0