How to Upload a File Into R From Workspace

How to upload your R lawmaking on GitHub: case with an R script on MacOS

  • Introduction
  • Prerequisite
  • Step-by-footstep guide
  • Additional notes

Introduction

Few days ago, 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 merely become into his office and show him on his figurer. Then I sent him several screenshots showing, pace past step, how to do so.

Correct before I deleted the screenshots I'd just taken, I thought that possibly they would be useful for other persons, so I wrote this commodity.

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

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

Prerequisite

In order to follow this guide and upload your R code on GitHub, you volition demand at least:

  • a GitHub business relationship
  • the GitHub Desktop application installed on your computer

Stride-by-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. Run across the repository on GitHub in case you want to encounter the concluding result earlier proceeding further.

Y'all ofttimes hear

"A picture is worth a thousand words"

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

Step 1: Go to github.com/login and sign in

Step 2: Become to your GitHub profile and create a new repository

Pace three: Set the proper name, description, audition and README file for the new repository

Be careful that if you choose to make information technology public, it will be visible to everyone. If you do non desire to share the code, but all the same want it to be uploaded on GitHub, choose the individual option.

Initializing the repo with a README file is not mandatory, merely I strongly recommend it so you will exist able to add data for this repo.

Step iv: You now see your new repository with only the README file

Step 5: Open up 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 figurer

Pace half dozen b: Clone the repository you just created on github.com to your computer

Step half-dozen c: Clone the repository y'all just created on github.com to your computer

Step vii: Your new repo appears on the GitHub Desktop awarding

Stride 8: Open up an R script and write your code

(See how to install R and RStudio if y'all are unfamiliar with it.)

Pace 9 a: Salve your R script in the corresponding folder

You can encounter the path to the folder in footstep 6 c, under "Local Path".

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

Step ten: Reopen GitHub Desktop, edit the commit championship (i) and click on the commit button (2)

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

Step xi: Push button the commit to github.com

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

Pace xiii: You now encounter 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 y'all need to share it, you lot can simply share the URL of the repo.

Boosted notes

If you demand to edit your code:

  1. Find the folder of the repo on your calculator past clicking on the push button "Show in Finder":

Find the folder of your repo on your computer

  1. Yous will be redirect to the binder of your repo on your computer. Open the R script you want to piece of work on, edit it and save it:

Open the R script, edit it and salvage it

  1. After your script is saved, do not forget to commit the changes and push the commit (encounter pace ten above).

In instance you need to encounter an one-time version of your code, you can see all commits past clicking on the commits tab accessible via the repo on github.com:

See all commits

Thank you for reading. I promise this article helped you lot to create a GitHub repository, and upload your R scripts so that it is bachelor to anyone.

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



Liked this post?

Go updates every time a new commodity is published.
No spam and unsubscribe someday.

Share on:

kerberwating.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 a File Into R From Workspace"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel