Using existing Shiny Apps inside a learnr tutorial?

Is it possible to simply embed an existing published Shiny App inside a learnr tutorial? There is great stuff out there and I'd hate to reinvent the wheel. Linking to the address just opens a new window. Is there a way to have that open inside the tutorial (i.e., like how videos are handled)?

I would check out using an knitr::include_app(url). This wraps around an iframe which allows displaying external urls (or shiny applications). Videos can be displayed directly on the site, but shiny applications need a backend server to process what is happening.

For more a live example, check out: https://bookdown.org/yihui/bookdown/web-pages-and-shiny-apps.html

```{r}
knitr::include_app("https://gallery.shinyapps.io/001-hello/", height = "500px")
```

You can also do this manually by adding an iframe directly. Change the src in the line below to point to an already hosted shiny application.

<iframe src="https://gallery.shinyapps.io/001-hello/" width="100%" height="500px" style="border:none;">

Thank you for the response. I used this code to test but all I get is a window that doesn't launch the app (or display it).

When I try to run the chunk individually, it yields the following error "Error in enc2utf8(x) : argument is not a character vector"

1 Like

I can not reproduce the Error in enc2utf8(x).

I can reproduce the iframe not appearing in the IDE. This is unexpected. I have submitted an issue to the RStudio IDE here: https://github.com/rstudio/rstudio/issues/7104

If I clicked "Open in Browser", it works in the browser. It also works if deployed / hosted somewhere such as shinyapps.io. (Tested on a internal Connect server)