Two images side by side in rmarkdown using knitr?

Viewed 889

In Rmarkdown I want to print two images from the web side by side. I'm trying this

```{r, echo=FALSE, out.width="33%", fig.align = "center", fig.cap="Examples of the FPTP bias: In Prairies (left) and Greater Toronto area (right). Source: www.fairvote.ca"}

knitr::include_graphics(
  c("https://www.fairvote.ca/wp-content/uploads/2019/12/Western-alienation-website-FPTP-page.png", "https://www.fairvote.ca/wp-content/uploads/2019/12/Toronto-Peel-halton-2019-results-website-FPTP.jpg")
  )

```

But instead I'm getting this - they are still printed one on top of the other:

enter image description here

Please advise. Note: I dont what to use cowplot or any other package.

1 Answers

Include the argument fig.show='hold'.

```{r, echo=FALSE, out.width="33%", fig.align = "center", fig.show='hold', fig.cap="Examples of the FPTP bias: In Prairies (left) and Greater Toronto area (right). Source: www.fairvote.ca"}
knitr::include_graphics(
  c("https://www.fairvote.ca/wp-content/uploads/2019/12/Western-alienation-website-FPTP-page.png",
    "https://www.fairvote.ca/wp-content/uploads/2019/12/Toronto-Peel-halton-2019-results-website-FPTP.jpg")
)
```

Here is what it looks like now: Here is what it looks like now.

Related