2

任何人都知道 Rmarkdown 的任何图片库包或创建画廊的好方法吗?我刚刚开始尝试一些香草代码,但还有很长的路要走。只是想在进入这个兔子洞之前与社区核实一下我是否遗漏了一些已知或明显的解决方案。

下面是一个工作示例。

在此处输入图像描述

---
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)
```
4

2 回答 2

2

最终创建了一个包,因为我找不到任何东西。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)
pixture(paths)
```

在此处输入图像描述

于 2022-01-07T20:04:25.220 回答
1

刚刚发现了slickR轮播。

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)

如果图像具有相同的尺寸或至少相同的高度,则效果最佳。

于 2021-07-02T16:08:24.973 回答