R Studio is an integrated development environment(IDE) for R Language. IDE is a GUI, where you can write your quotes, see the results and also see the variables that are generated during the course of programming. R Studio is available as both Open source and Commercial software. It is also available as both Desktop and Server versions and also available for various platforms such as Windows, Linux, and macOS.
Git is an open-source version control system. It means that whenever a developer develops some project (like an app) or something, he/she constantly update it catering to the demands of users, technology, and whatsoever it maybe. Version control systems keep these revisions straight, storing the modifications in a central repository. It allows developers to easily collaborate, as they can download a new version of the software, make changes, and upload the newest revision. Every developer can see these new changes, download them, and contribute. Git is used to storing the source code for a project and track the complete history of all changes to that code, while GitHub is a cloud-based platform built around the Git tool. So it’s necessary to upload your project on GitHub.
Prerequisite: Before going through this article consider that one must already have a GitHub account along with R studio installed on their computer.
Now we have both RStudio and a GitHub account, it’s time to link them together so that you can maximize the benefits of using RStudio in your version control pipelines. Here is the step by step process to link GitHub and RStudio.
Step 1: In RStudio, Go to Tools > Global Options > Git/SVN
Then click on Create RSA Key and when this completes, click Close. Following this, in that same window again, click View public key and copy the string of numbers and letters. Close this window.
Now you have created a key that is specific to you which we will provide to GitHub, so that it knows who you are when you commit a change from within RStudio.
Step 2: Now Go to github.com, log-in if you are not already, and Go to your account settings. There, Go to SSH and GPG keys.
Now click New SSH key. Paste in the public key you have copied from RStudio into the Key box and give it a Title related to RStudio. Confirm the addition of the key with your GitHub password.
GitHub and RStudio are now linked. From here, we can create a repository on GitHub and link to RStudio.
Step 3: Now let’s create a new repository and edit it in RStudio. On GitHub, create a new repository(github.com > Your Profile > Repositories > New). Name your new test repository and give it a short description. Click Create Repository. Copy the URL for your new repository.
Step 4: In RStudio, Go to File > New Project. Select Version Control.
Then Select Git as your version control software. Paste in the repository URL from before, select the location where you would like the project stored. When done, click on Create Project. Doing so will initialize a new project, linked to the GitHub repository, and open a new session of RStudio.
Step 5: Create a new R script(File > New File > R Script) and copy and paste the following code and save the file.
Once that is done, looking back at RStudio, in the Git tab of the environment quadrant, you should see your file you just created. Click the checkbox under Staged to stage your file.
Then click Commit. A new window should open, that lists all of the changed files from earlier, and below that shows the differences in the staged files from previous versions. In the upper quadrant, in the Commit message box, write yourself a commit message. Click Commit. Close the window.
So far, you have created a file, saved it, staged it, and committed it the next step is to push your changes to your online repository. Push your changes to the GitHub repository and you are done.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.