Week 4: Contributing to Open-Source Packages

Stat 431


In the last module, you took a look at the meangirls package by Regina George.

Now let’s help Regina make her package even better.

The usethis package will make this process easy and foolproof. Make sure you have it installed now.


Time Estimates:
     Videos: 30 sec
     Readings: 20 min
     Activities: 40 min
     Check-ins: 5



Extra Resources:

Get set up

The first thing you need to do when you want to contribute to someone else’s package is to fork the package.

Recall that a fork is very different from a clone. A clone simply copy-pastes the repository, while a fork retains its link to the original repository.

Now, we could go through the tedious process of forking the repository, then all the steps after that to get it open in your local computer’s RStudio.

Instead, let’s do all these steps in one with usethis. Open up a new RStudio session, load the usethis package, and then run:

A lot of output will print out.

Here’s what this does:

  • Forks the meangirls repo, owned by Cal-Poly-Advanced-R on GitHub, into your GitHub account.
  • Clones your praise repo into a folder named “meangirls” on your desktop (or similar).
  • Does additional git/GitHub setup:
    • Sets your origin remote (the repo you can push directly to) to be your own forked copy of the “meangirls” repo.
    • Sets your upstream remote (the original version that you will later Pull Request) to be the “meangirls” repo owned by Cal-Poly-Advanced-R
    • Sets the master branch to be the original repo’s main branch, so you can pull future edits that Regina makes (“upstream changes”) in the future.
  • Opens a new instance of RStudio in the meangirls R project.

Alternative approach

It is also possible to do this steps without create_from_github, if you prefer or if it is not playing nice with your machine.

  1. On GitHub, navigate to the package repo and click “Fork”.
  2. Using GitHub Desktop (or your preferred method), clone your new forked package to your local machine.
  3. Navigate to the folder where you cloned the package, and open the .Rproj.

Check-In 1: Forking setup


Take a screenshot of the console output from create_from_github

OR

Take a screenshot of your RStudio window with the package project open.

Canvas Link     

Make some simple changes

We are now ready to get our hands dirty with this package.

First, build the package.

You can do this by typing Cmd/Ctrl-Shift-B, or by clicking in the “Build” pane: