Skip to content

How to add a package page entry

Holtz Yan edited this page Oct 30, 2023 · 6 revisions

Introduction

The R graph gallery has a section about the most used packages: https://r-graph-gallery.com/best-dataviz-packages.html

This document explains how to add an entry to this section.

Working environment

Start by forking the GitHub repository.

Then copy-paste an existing package blog-post. I suggest starting from package/patchwork.Rmd. The name of the new file must be the name of the package: package_name.Rmd. Example: ggstatsplot.rmd

Let's update the template with your content.

BlogPost header:

  • title: written in big on top of the post
  • logo: name of the package. It will be linked with a png file of the same name
  • descriptionMeta: description for google, in the head of the document
  • descriptionTop: first sentence at the very top. Use markdown to format. Use <br/> to skip line for more air.
  • documentationLink: link toward the official doc. do not include https:// in link

Note that the post always starts with

```{r global options, include = FALSE}
knitr::opts_chunk$set( warning=FALSE, message=FALSE)
```

Do not remove this.

Best practice

Titles of level 1 must be written as:

# Quick start
***

Always cite the author. Find number of stars on GitHub.

Respect the post structure in patchwork.rmd

Gallery examples

The blog post finishes by listing all the examples of the R graph gallery using the package. Adding this list with image thumbnails is hard. Here is the process:

  • Find all the charts in the gallery using the package. In VS code, you can open the whole folder and search for library(package_name) to find all the occurrences.

  • Let's say I found an occurence in a file called 328-hexbin-map-of-the-usa.rmd. In the code base I can then find a code snippet that displays an image that links to this blogpost. Something that looks like:

          <div class="col-md-4 col-sm-6 portfolio-item">
            <a class="portfolio-link" href="328-hexbin-map-of-the-usa.html">
              <div class="portfolio-hover">
                <div class="portfolio-hover-content">
                  <p>Basic Choropleth</p>
                  <hr />
                  <p class="explanation_portfolio">
                    Color each hexagone with a color that represents a numeric
                    value. It's a hexbin choropleth map.
                  </p>
                </div>
              </div>
              <img
                class="img-fluid imgOfPortfolio"
                src="img/graph/328-hexbin-map-of-the-usa3.png"
                alt=""
              />
            </a>
          </div>

Find all the above code chunks related with all the blogpost using the library of interest.

  • Create a bigger code chunk that groups them all. You must wrap them like this:
<section class="bg" id="portfolio" style="padding-top: 10px">
  <div class="container">
    <div id="portfolio-items" class="row">
       ... example 1
       ... example 2
       ...
    </div>
  </div>
</section>
  • replace the image source path. img/...... must become ../img/....... Before:
src="img/graph/328-hexbin-map-of-the-usa3.png"

After:

src="../img/graph/328-hexbin-map-of-the-usa3.png"

Always open your newly created file in your browser. For instance, read file:///Users/holtzy/Desktop/R-graph-gallery/package/patchwork.html to check that it looks good.

Make the package listed

There is a file called best-dataviz-packages.html that lists all the package posts in the gallery. We need to list the package you just wrote about. To do so, add a section that looks like:

          <a href="./package/gghighlight.html" class="col-4 col-md-2">
            <div class="package-page-hex">
              <div class="package-page-hex-background">
                <img src="img/r-package-img/gghighlight.png" />
              </div>
            </div>
            <p>gghighlight</p>
          </a>