r - Rmarkdown 图片库
问题描述
任何人都知道 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)
```
解决方案
最终创建了一个包,因为我找不到任何东西。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)
```
推荐阅读
- mysql - 如何为以下结构制定查询和视图?
- python - 如何在熊猫列具有 NULL 值时将其转换为 int?
- python - 无法反序列化为对象:类型,KeyError:'键:int;值:str'
- c# - 如何通过 c# win app 将 Crystalreport 导出为 pdf 文件?(每次导出到 1 个文件的 1 条记录。)
- javascript - 是否可以通过 transform:rotate(Xdeg) 获得平滑的 CSS 过渡到 0 度?
- angularjs - 将 angularJS 指令转换为 Angular 打字稿
- php - 从 json 中创建一个具有未知数量循环的多维关联数组
- java - 无法调试 Lambda 表达式 IntelliJ Ultimate 2018.1
- regex - 查找部分重复的行,保留第一个实例,其余部分保持不变
- r - 通过两列组合重新组织列