mjhalwa
mjhalwa

Reputation: 533

How to embed a shiny application into an Rmarkdown html document

I would like to create an html document with RMarkdown, containing text, Rcode and somewhere in between a shiny application.

How to generate html-code from the shinyApp function? Or: How to generate an html file, from RMarkdown containing a shiny app instead of e.g. a plot

I hope you have some idea for me.

Upvotes: 7

Views: 10020

Answers (3)

Zhuoer Dong
Zhuoer Dong

Reputation: 639

I don't really understand what you mean by "a shiny application". If you have already set up a server side application, i.e. others can access your application via URL, you can try the following approach.

See https://bookdown.org/yihui/bookdown/web-pages-and-shiny-apps.html, second paragraph.

A related function is knitr::include_app(), which is very similar to include_url(), and it was designed for embedding Shiny apps via their URLs in the output.

enter image description here

Upvotes: 4

Scott Clayton
Scott Clayton

Reputation: 1

'Note: If you are familiar with R Markdown, you might expect RStudio to save an HTML version of an interactive document in your working directory. However, this only works with static HTML documents. Each interactive document must be served by a computer that manages the document. As a result, interactive documents cannot be shared as a standalone HTML file.'

https://shiny.posit.co/r/articles/build/interactive-docs/

Upvotes: 0

petzi
petzi

Reputation: 1636

If I understand your question correctly then maybe the following URL could be of help for you:

https://bookdown.org/yihui/rmarkdown/shiny-start.html

As you can see: You don't have to follow the Shiny skeleton template. The only thing to do: You have to add the line runtime: shiny into the YAML-header and publish the .Rmd file in the normal way, e.g. you have to include a standard r code snippet in your RMarkdown document where you can write your shiny code.

I hope this is helpful.

Upvotes: 2

Related Questions