Using RStudio with GitHub

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

Configuring PyCharm to Work With Enthought Canopy and GitHub

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.

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

2Step 2:

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

3

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

4

Step 3:

Copy the URL of the Git repository you have created.

5

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.

6

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

7

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.

8

Step 5:

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

9

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.

10

Step 6:

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

11

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.

12

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.

13

Now click on the Push button.

14

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

15

Then enter your GitHub password and press OK button.

16

Step 7:

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

17

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

18

Step 8:

Again in the RStudio editor add another line as

print(“Second Commit”)

Click on the Git button and select Commit option.

23

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.

19

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.

20

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

21

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

22

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.

23

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

24

Conclusion

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

Leave a Reply

Your email address will not be published. Required fields are marked *