9.3 Embed a web page
If you have the webshot2 package (Chang 2023) and Chrome installed (see Section 9.2), you can embed any web page in the output document through knitr::include_url()
. When you pass a URL of a web page to this function in a code chunk, it will generate an <iframe>
(inline frame) if the output format is HTML, and a screenshot of the web page for other output formats. You can view the actual page in the inline frame.
Most chunk options related to figures also work for knitr::include_url()
, such as out.width
and fig.cap
.
If you have published a Shiny app publicly on a server, you can use knitr::include_app()
to include it, which works in the same way as include_url()
. Section 2.11 of the bookdown book (Xie 2016) contains more details about include_app()
and include_url()
.