2

I would like to render a rmarkdown as pdf that as some html (leaflet) in it.

Here is the YAML header:

date: '2022-07-29'
output: pdf_document
always_allow_html: true

My markdown would not render as pdf unless I included the "always_allow_html". However, the leaflet plots I want to show up are not showing up in the pdf format. Here is a snippet of code of the plot:

```{r map_of_schools, fig.height= 5, fig.width= 5, message=FALSE}
    map <- leaflet() %>%
  addTiles() %>%
  addCircleMarkers(
    data = safepassageschools,
    color = ~pal(treatment),
    radius = 0.5) %>%
  addLegend(
    colors = c("red", "blue"),
    labels = c("Did Not Participate", "Participated"),
    title = "Participation in Safe Passage Program",
    position = "bottomleft"
  )

map
  • What errors are you receiving and what is showing up or not? Please provide a reproducible example. – socialscientist Jul 29 '22 at 05:42
  • 1
    Not sure what exactly you are expecting. TBMK the only thing you could achieve is to add a screenshot of your leaflet map to a non-HTML output format: "knitr will try to embed a screenshot of the widget if you have installed the R package webshot and the PhantomJS package" (see https://bookdown.org/yihui/rmarkdown/interactive-documents.html). So make sure you have installed these packages. – stefan Jul 29 '22 at 06:41
  • the minimal would be to output to `html_document` with the HTML document, then *print to pdf* from the browser, Other wise you might need another way to graph individual screenshots of the map to plot. – Daniel_j_iii Aug 01 '22 at 04:09

0 Answers0