How to Upload Files to Github Using R

How to upload your R code on GitHub: example with an R script on MacOS

  • Introduction
  • Prerequisite
  • Stride-by-step guide
  • Boosted notes

Introduction

Few days agone, a colleague asked me how to upload some R code on GitHub in order to make it accessible to everyone. Due to the lockdown, I could non just become into his function and show him on his computer. And then I sent him several screenshots showing, step past step, how to exercise so.

Right earlier I deleted the screenshots I'd but taken, I idea that perhaps they would be useful for other persons, so I wrote this commodity.

Note 1: The screenshots have been taken on MacOS and I have not tested it on Windows. Do not hesitate to let me know in the comments whether it is like or not on other operating systems.

Notation 2: There must exist other means to do it, but the method shown below is (in my opinion) easy and works well.

Prerequisite

In order to follow this guide and upload your R lawmaking on GitHub, you will need at to the lowest degree:

  • a GitHub account
  • the GitHub Desktop application installed on your computer

Step-past-step guide

For this guide, I use a R script created to plot the evolution of the hospital admissions due to COVID-19 in Belgium. Meet the repository on GitHub in case you want to run into the concluding event before proceeding further.

You ofttimes hear

"A film is worth a k words"

So hither is without further ado how to upload your R script on GitHub in images:

Pace ane: Get to github.com/login and sign in

Step two: Go to your GitHub contour and create a new repository

Step iii: Set the name, description, audition and README file for the new repository

Be careful that if you choose to brand it public, it volition be visible to everyone. If you do not want to share the code, but still want information technology to be uploaded on GitHub, cull the private option.

Initializing the repo with a README file is not mandatory, just I strongly recommend it so you lot will be able to add information for this repo.

Stride 4: You now come across your new repository with just the README file

Step 5: Open the GitHub Desktop application and sign in with your GitHub account

Step 6 a: Clone the repository you just created on github.com to your computer

Step vi b: Clone the repository you only created on github.com to your reckoner

Step six c: Clone the repository you just created on github.com to your computer

Pace 7: Your new repo appears on the GitHub Desktop application

Step 8: Open an R script and write your code

(See how to install R and RStudio if you are unfamiliar with it.)

Stride 9 a: Save your R script in the respective binder

Yous tin meet the path to the folder in step six c, under "Local Path".

Step 9 b: Save your R script in the corresponding folder

Step 10: Reopen GitHub Desktop, edit the commit title (one) and click on the commit button (ii)

In stride 10, make certain that the current repository (see top left) is the repo you are currently working on.

Step 11: Push button the commit to github.com

Step 12: On your GitHub profile, click on the newly created repository

Step thirteen: You lot now see your script which has been added to the repository

Your R code is now available online via the new repository on your GitHub profile. If you demand to share it, you can simply share the URL of the repo.

Boosted notes

If you lot need to edit your code:

  1. Find the folder of the repo on your figurer by clicking on the button "Show in Finder":

Find the folder of your repo on your computer

  1. Y'all will be redirect to the binder of your repo on your estimator. Open the R script y'all want to piece of work on, edit it and save information technology:

Open up the R script, edit it and salvage information technology

  1. Afterward your script is saved, do not forget to commit the changes and push button the commit (see step ten above).

In case you need to meet an old version of your code, you can see all commits by clicking on the commits tab accessible via the repo on github.com:

See all commits

Thanks for reading. I hope this commodity helped y'all to create a GitHub repository, and upload your R scripts so that it is bachelor to anyone.

As ever, if yous have a question or a suggestion related to the topic covered in this article, please add it as a annotate then other readers can benefit from the word.



Liked this post?

Become updates every time a new article is published.
No spam and unsubscribe someday.

Share on:

letsonripplexprem.blogspot.com

Source: https://statsandr.com/blog/how-to-upload-r-code-on-github-example-with-an-r-script-on-mac-os/

0 Response to "How to Upload Files to Github Using R"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel