Contributing to Open Source Football

A brief guide how to contribute content.

Sebastian Carl https://twitter.com/mrcaseb (nflfastR)https://twitter.com/nflfastR
01-21-2022

Preface

The primary goal of Open Source Football is to make football-related analysis and corresponding code publicly available. To achieve this, we need volunteers who are willing to make a contribution.

Articles posted on Open Source Football are authored using Distill for R Markdown. If you would like to contribute, you’ll need to have installed R and R Markdown. However, this does not mean that are limited exclusively to R code because R Markdown supports many other languages as well! You’ll need R and R Markdown to create the post and the formal structure but the most important thing - your code and its output - can be anything compatible with R (please see Ben’s python contributing example).

This guide is intended to help all contributors prepare articles for publishing. If you have questions or think something is unclear or wrong please create an issue and we will look into it.

Brief Overview

Here is a very brief overview of what is needed. The next section will have much more detail on each of these steps.

The steps below assume that you have RStudio and git (I highly recommend Hadley’s git section in “R packages”) installed.

Contributing to someone else’s package or project became much more convenient with the usethis pull request helpers. We will use these in the following sections, so please read the linked article.

  1. Install the R packages you will need to contribute (Note the minimum version requirement of distill)
  2. Fork the website repository to your GitHub (you’ll need a free account) and clone it to your local computer
  3. Create a new branch
  4. Create the new article (see the repo for some examples and check the Distill for R Markdown website) and please don’t forget to add metadata and chunk options as discussed in the next section
  5. Commit all to your post related files
  6. Submit the pull request and let us review your code https://usethis.r-lib.org/articles/pr-functions.html#submit-pull-request (please see Push your work into your repo for details what you should do to avoid merge conflicts)

With the last step we will be notified and will take a look at your article, suggest changes as necessary, then publish it when it’s ready by merging it into the main repository.

More Detailed Instructions

Before you start, don’t forget to read the article on usethis pull request helpers.

Install the packages

Install the packages distill, usethis and rmarkdown with

install.packages(c("distill", "usethis", "rmarkdown"))

Important! Rendering of the site will fail or be incomplete if an outdated version of distill is installed, so please check if you have installed distill >= 1.0 by running

paste0("You are running distill v", utils::packageVersion("distill"))
[1] "You are running distill v1.3"

Fork and Clone the Repository

The “Fork” is your own copy of the Open Source Football Github Repository. You can clone it to get your own local copy. There are many ways to accomplish these two steps, but I highly recommend

usethis::create_from_github("nflverse/open-source-football")

This will fork the repo, clone it to your computer and open the project in a new RStudio session. Click here for more details.

Create a new Branch and Start Working

The process of contributing starts now by creating a new branch (please try to choose a descriptive name). It is good practice to make your changes in a new branch instead of the main branch, so please make sure not to skip this step.

usethis::pr_init(branch = "bens-apa-tiers")

Click here for more details.

Start working on the post

Create the new article by running

distill::create_post("Title of your post")

This will create a new folder in _posts and name it with the current date and your chosen title. Additionally the RMarkdown file in which you will write your post will be opened automatically. It will look something like this

We need to tweak the metadata as well as the chunk setup a little bit in order for the post to meet our expectations. Please have a look at example file for a little template.

Now you are ready to write your post. Please see Distill for R Markdown as well as some of the already published posts. And if you feel like you need more information about R Markdown please feel free to check the R Markdown Cookbook.

Commit your Changes in your Branch

Using git within RStudio is easy because you can do it graphically. However, it doesn’t make sense to provide a ton of screenshots and text here. Instead I recommend two sources:

Commit all files which are related to your post and go on with the last step. There are 4 files not related to your post which may cause merge conflicts when you push them without updating them before your pull request. To avoid this, please run the following code right before you commit all your files:

source("https://raw.githubusercontent.com/nflverse/open-source-football/master/_update_con_files.R")

If you forget this step, you can still create the pull request and GitHub will inform you of the conflicts. If there are conflicts, run the above line, then commit and push the updated files: docs/index.html, docs/index.xml, docs/posts/posts.json, and docs/sitemap.xml.

Submit the Pull Request

The following code pushes any local changes of your code to GitHub and puts you in position to make your pull request:

usethis::pr_push()

This launches a browser window with the prepared pull request on Github. You will have to click “Create pull request”, add some description, and finally submit it. Click here for more details.

Now you are done. We will start reviewing your pull request and make sure to publish it. Thanks for your contribution!

Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY-NC 4.0. Source code is available at https://github.com/nflverse/open-source-football, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".