My Thoughts, My Learnings

Introduction

This tutorial Introduces the reader to step by step instruction in using RStudio IDE with GitHub.

Using RStudio with GitHub

All these steps are tested on a Windows 10 machine with RStudio version 0.99.x. I assume that you have already already installed RStudio and GitHub. If you haven’t still installed GitHub then please follow the first 6 steps of Install GitHub portion found at

Assuming that both RStudio and GitHub is configured properly, type the following two command at the command prompt.

git config –global user.name “your GitHub account name”

git config –global user.email “GitHubEmail@something.com”

Step1:

Go to your GitHub account and create an repository. To create an repository go to the upper right corner and click on the “+” sign.

A pop up appears asking you to create a New repository. Click on New repository.

Step 2:

You will be taken to a new page and in the Repository name box write as RStudioGitHubTutorial and click on CreateRepository button.

You will be taken to the next page giving you more information about the repository you have just created.

Step 3:

Copy the URL of the Git repository you have created.

Step 4:

Start your RStudio. Go to File menu -> Click on New Project.

A window appears where in you have different ways of creating a project.

Click on Version Control.

You’ll be taken to the next window and click on Git option.

Paste the URL that you copied from step 3 in the Repository URL text box.

The Project directory name text box automatically gets filled.

Specify the directory under which this project has to be created. In my case it’s C:/RWork.

Step 5:

Go to File menu -> Select New File -> click on R Script.

This creates an empty R file. Save this file by clicking on the Save button and name this file as Tutorial.R.

Type the following line in the editor.

print “First Commit”

Save the file.

Step 6:

Click on the Git button as shown in the below figure and select Commit option.

You’ll be taken to a new window. Select all the check boxes in the left pane and in the in the Commit Message pane type as First Commit and click on Commit button.

Another windows appears saying that the commit has been carried out at the local repository. Your local repository is the as that of the Project Directory which you created in Step 4. Click on Close button.

Now click on the Push button.

You’ll be asked to enter your GitHub User Name as shown in below figure. Enter your GitHub account name and press OK button.

Then enter your GitHub password and press OK button.

Step 7:

Navigate to the repository in your GitHub account and you can see that many new files have been added.

Click on Tutorial.R file to view it’s contents.

Step 8:

Again in the RStudio editor add another line as

print(“Second Commit”)

Click on the Git button and select Commit option.

In the window that appears, on the left pane select the check box and in the Commit message right pane type Second Commit and click on Commit button.

Click on the Push button found in the right top corner. You will be asked to enter your GitHub User Name. Fill the text box with your Git Hub account name and click OK button.

Fill the text box with GitHub account password and click OK button.

You can view the latest changes by navigating to your online GitHub Account and by clicking on the Tutorial.R button.

If you want to see the history of all the changes done to the file then again click on GIT button and select History option as shown in the below figure.

Click on the appropriate Commit Message and select View File link as show in the below figure.

Conclusion

This article gives you step by step instructions on how to work with RStudio and GitHub.