1

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

What I know so far

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).

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?

Example use

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

Notes

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.

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

ismirsehregal
  • 30,045
  • 5
  • 31
  • 78
stevec
  • 41,291
  • 27
  • 223
  • 311

1 Answers1

4

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

Then run:

```{r}
slickR::slickR(
    list.files(objpath,full.names = TRUE,pattern = 'png'),
    height = 200,
    width = '95%')
```
J_F
  • 9,956
  • 2
  • 31
  • 55