Rmarkdown image gallery

879 Views Asked by At

Anyone know of any image gallery packages for Rmarkdown or a good way to create a gallery? I have just started to experiment with some vanilla code, but there is a long way to go. Just wanted to check with the community if I am missing some known or obvious solutions before I go down this rabbit hole.

Below is a working example.

enter image description here

---
title: "Gallery"
output:
  html_document:
    theme: united
---

<br>

```{r,include=FALSE}
paths <- c(
  "https://images.pexels.com/photos/7604423/pexels-photo-7604423.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/5483373/pexels-photo-5483373.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/4982737/pexels-photo-4982737.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/3773652/pexels-photo-3773652.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
)
len <- length(paths)
width <- paste0(100/len,"%")
```
```{r,echo=FALSE,fig.show="hold",out.width=width}
knitr::include_graphics(paths)
```


```{r,include=FALSE}
paths <- c(
  "https://images.pexels.com/photos/3845111/pexels-photo-3845111.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260",
  "https://images.pexels.com/photos/3933996/pexels-photo-3933996.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260",
  "https://images.pexels.com/photos/1033729/pexels-photo-1033729.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
)
len <- length(paths)
width <- paste0(100/len,"%")
```

```{r,echo=FALSE,fig.show="hold",out.width=width}
knitr::include_graphics(paths)
```
2

There are 2 best solutions below

0
On BEST ANSWER

This is an option: https://github.com/royfrancis/pixture

---
title: "Gallery"
output:
  html_document:
    theme: united
---


```{r}
paths <- c(
  "https://images.pexels.com/photos/7604423/pexels-photo-7604423.jpeg",
  "https://images.pexels.com/photos/5483373/pexels-photo-5483373.jpeg",
  "https://images.pexels.com/photos/4982737/pexels-photo-4982737.jpeg",
  "https://images.pexels.com/photos/3773652/pexels-photo-3773652.jpeg"
)

library(pixture)
pixgallery(paths)
```

enter image description here

0
On

Just discovered slickR carousel.

library(slickR)

paths <- c(
  "https://images.pexels.com/photos/7604423/pexels-photo-7604423.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/5483373/pexels-photo-5483373.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/4982737/pexels-photo-4982737.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/3773652/pexels-photo-3773652.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940",
  "https://images.pexels.com/photos/3845111/pexels-photo-3845111.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260",
  "https://images.pexels.com/photos/3933996/pexels-photo-3933996.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260",
  "https://images.pexels.com/photos/1033729/pexels-photo-1033729.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"
)

slickR(obj=paths)+ 
  settings(dots = TRUE)

It works best if images have the same dimensions, or at least the same height.