This package makes it easy to create an gallery for displaying small R vignettes, or "snippets". View an example here!
Install with devtools:
devtools::install_github("dgrtwo/rgallery")
You'll need Jekyll and git installed as well.
To create and edit your gallery, simply:
-
Set up a gallery by running the following commands in R:
library(rgallery) create_gallery("my-gallery") build_gallery("my-gallery")
This downloads the default r-gallery setup and builds it.
-
Back in the command line, go into the directory and start a Jekyll server:
cd my-gallery jekyll serve --watch
-
Visit your local gallery at http://127.0.0.1:4000/.
-
To create additional snippets, add
.Rmd
files to the_R
directory. Make sure you includelayout: snippet
in the YAML header. Then dobuild_gallery("my-gallery")
to compile them. -
To publish your gallery online for free, use GitHub pages: just make a public repository and push to the
gh-pages
branch. Note: You'll need to change theurl
parameter in_config.yml
tohttp://<yourname>.github.io/<repo-name>
.
That's all there is to it!
You can customize the global knitr options (for example, cache = TRUE
or echo = FALSE
) by adding to the knitr-options
block in _config.yml
:
# rgallery options
knitr-options:
message: false
- Categories and tags
- Allowing multiple snippets to be connected, and therefore compiled in a row, to illustrate a larger topic or workflow
- Allowing snippet submission, as a pull request to the repository, directly from R (i.e.
submit_snippet('my_snippet.Rmd', repo = 'dgrtwo/big-gallery')
). Preferably allow the repository owner to build and approve the snippet from within R as well. - Flexible front-ends, including alternatives to Jekyll