How to push your project to GitHub from RStudio

How to push your project to GitHub from RStudio

RStudio to GitHub

Table of contents

No heading

No headings in the article.

In this article, I will take you through the step-by-step walkthrough I had the opportunity to guide members of DeKUT{R} Community, a student-led data science community at Dedan Kimathi University in Kenya during our semester weekly meetups.

To begin with, you have to install R from the Comprehensive R Archive Network CRAN https://cran.r-project.org/

Image description

Type R --version on the terminal to view the version of R you have installed.

Secondly, install RStudio IDE which is the best coding environment for R built by Posit https://posit.co/downloads/

Image description

RStudio IDE Screenshot

Another requirement is Git. Git is a version control system that we will use to track changes to our project code. You can download the appropriate version for your operation from https://git-scm.com/

Image description

Check the Git version already installed

git --version

To install Git on Ubuntu/Debian

sudo apt install git

The last requirement you need is to create a GitHub account, where we will create a repository to host our project source code. Navigate to https://github.com/ and signup

Image description

Creating a repository on GitHub

A repository is a "container" which holds all your project files and each file revision history.

Image description

Give your repository an appropriate name and a brief description then, create a repository.

Image description

Bravo! You have created a repository on GitHub.

Image description

Setting up your project on RStudio

Create a new project and select the Version Control option on the new project wizard

Image description

Select version control

In the new project wizard select GIT as your version control to use

Image description

Remember the repository we created on GitHub, it is time to use the repo's URL.

Image description

Copy the repository URL and paste it on the Repository URL text box as shown below and click Create Project.

Image description

Load your project

For this article, I conducted exploratory data analysis and data visualization on the Titanic data in a markdown file.

To stage my file ready for commit, navigate to the Git Tab in the Environmental pane of the IDE.

Image description

Check the files you wish to stage for commit and click 'commit'.

The RStudio commit changes window will pop up, where you can view the project files and add a commit message as shown below.

Image description

Add a suitable commit message and commit your staged files.

Image description

At this point, you have completed a commit of your files and they are ready to be pushed to GitHub.

Close the Git Commit window and click the green Push arrow above the commit message text box.

Image description

You will be prompted to provide your GitHub username

Image description

Provide your generated GitHub access Token as your password and click OK.

Image description

Learn how to get your personal access token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

DONE!

You have successfully pushed code from RStudio to GitHub

Image description

You can verify this by switching back to your GitHub account on your browser and navigate to your project repository in my case Jaribio.

Image description

The repository link to visualizing Titanic is available here https://github.com/KaraniWachira/Jaribio

Thank you for reading!

DeKUT {R} Community Twitter: https://twitter.com/RDekut