Using GitHub in R

· by Jo Hardin and Hunter Glanz · Read in about 3 min · (557 words) ·

Once you get the hang of using Projects in RStudio, you may be inclined to collaborate with others on the same project. If so, you will want to set up a Project that links directly to GitHub. By having your project on GitHub (and regularly saving it / updating it on GitHub), your collaborators will always have access to the most up to date analysis information.

Previous posts have described working with R Projects and working with GitHub.

Good News!

If you have already become familiar with using Projects in RStudio and GitHub with collaborative projects, then putting them together is a matter of opening the project in RStudio by cloning the Git repository. If you have not yet set Git up within your RStudio IDE, your best strategy for problem solving is Jenny Bryan’s Happy Git and GitHub for the useR website,

Project Step 1

Project Step 2

Project Step 3

Working with GitHub in R

After your project is cloned from GitHub into the RStudio IDE, you should find the Git command interface (usually) in the top right corner of your RStudio IDE. From there, you can pull, commit, and push. You will also have the ability to investigate the diff files and stage/unstage etc.

Git Interface

Teaching with GitHub in R

Amidst numerous data science topics in this blog you’ve been exposed to the wonders of the tidyverse, R Markdown, projects in RStudio, and GitHub. All of these tools enable a more productive and reproducible data science workflow. Not only are they skills and tools that students will be working with on the job, but they provide students better engagement with data science topics while in school. To wit, all of these technologies should be used in unison as an integrated part of the classroom experience.

GitHub is the perfect place to host course materials so that students can easily pull what they need and contribute their work as needed via objects like R Markdown documents within projects.

It should be noted that not all Git operations can be done within the RStudio interface (e.g. git stash), but the list of resources below will be a great first step towards learning what can be done.

Learn more

About this blog

Each day during the summer of 2019 we intend to add a new entry to this blog on a given topic of interest to educators teaching data science and statistics courses. Each entry is intended to provide a short overview of why it is interesting and how it can be applied to teaching. We anticipate that these introductory pieces can be digested daily in 20 or 30 minute chunks that will leave you in a position to decide whether to explore more or integrate the material into your own classes. By following along for the summer, we hope that you will develop a clearer sense for the fast moving landscape of data science. Sign up for emails at!forum/teach-data-science (you must be logged into Google to sign up).

We always welcome comments on entries and suggestions for new ones.