在 Rmarkdown 中创建轮播? [英] Create a carousel in Rmarkdown?

查看:100
本文介绍了在 Rmarkdown 中创建轮播?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何快速简便的方法可以在 Rmarkdown 中创建一个简单的轮播医生?

Is there any quick and easy way to create a simple carousel in an Rmarkdown doc?

我找到了 slickr 但遇到了错误设置选项和编织(错误可能是我/mac 特有的——我现在不确定).

I found slickr but run into errors setting options and knitting (the errors could be specific to me / mac - I am not sure at this point).

我相信可以将 html/javascript 硬编码到 RMarkdown 文档中,即与在任何其他(常规)html 文档中执行轮播相同的方式(即使用 html 代码 这里)-但我想知道是否有本地(R)方式?

I believe it would be possible to hard code html/javascript into the RMarkdown doc i.e. the same way a carousel would be done in any other (regular) html document (i.e. using the html code here)- but I wonder if there's a native (R) way?

在我的特定用例中,我试图显示多个复杂的 ggplots,每个都足够复杂,使它们需要自己的空间(即没有分面或 grid.arrange 作为每个的大小情节会变得太小而无法阅读

In my particular use case, I'm trying to display multiple complicated ggplots which are each sufficiently complex to make them require their own space (i.e. not faceted or grid.arrange as the size of each plot will get too small to read

这是我试过的 slickr 代码

Here is the slickr code I tried

library(texPreview)
library(slickR)


objpath <- file.path(getwd(),"slickr_files/figure-html")

if(!dir.exists(objpath)) { dir.create(objpath,recursive = TRUE) }

tex_opts$set(
  fileDir    = objpath, # path to save output
  returnType = 'html', # return images ready for html 
  imgFormat  = 'png' # return png images
)


knitr::kable(mtcars,'latex') %>%
  texPreview::tex_preview(stem = 'kable-1')
# ! LaTeX Error: File `standalone.cls' not found.

附注,如果有更好的方法来提供许多(例如 > 3 个)不涉及分面的大而详细的图,grid.arrange 或(我目前的首选选项)tabbing,请在评论中提出建议

A side note, if there's a better way of providing many (e.g. > 3) large, detailed plots that doesn't involve faceting, grid.arrange, or (my current preferred option) tabbing, please give a suggestion as a comment

推荐答案

example 对我来说很好用.请务必将您的绘图保存在文件夹 slickr_files/figure-html 中.

The example works fine for me. Be sure to save your plots in the folder slickr_files/figure-html.

然后运行:

```{r}
slickR::slickR(
    list.files(objpath,full.names = TRUE,pattern = 'png'),
    height = 200,
    width = '95%')
```

这篇关于在 Rmarkdown 中创建轮播?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆