<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>GitHub on Stats and R</title>
    <link>https://statsandr.com/tags/github/</link>
    <description>Recent content in GitHub on Stats and R</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sun, 24 May 2020 00:00:00 +0000</lastBuildDate>
    
	<atom:link href="https://statsandr.com/tags/github/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>How to upload your R code on GitHub? An example with an R script on MacOS</title>
      <link>https://statsandr.com/blog/how-to-upload-r-code-on-github-example-with-an-r-script-on-mac-os/</link>
      <pubDate>Sun, 24 May 2020 00:00:00 +0000</pubDate>
      
      <guid>https://statsandr.com/blog/how-to-upload-r-code-on-github-example-with-an-r-script-on-mac-os/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#introduction&#34; id=&#34;toc-introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#prerequisite&#34; id=&#34;toc-prerequisite&#34;&gt;Prerequisite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#step-by-step-guide&#34; id=&#34;toc-step-by-step-guide&#34;&gt;Step-by-step guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#additional-notes&#34; id=&#34;toc-additional-notes&#34;&gt;Additional notes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#conclusion&#34; id=&#34;toc-conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;div id=&#34;introduction&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;p&gt;A 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 not just go into his office and show him on his computer. So I sent him several screenshots showing, step by step, how to do so.&lt;/p&gt;
&lt;p&gt;Right before I deleted the screenshots I’d just taken, I thought that perhaps they would be useful for other persons, so I wrote this article.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;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 similar or not on other operating systems.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note 2: There must be other ways to do it, but the method shown below is (in my opinion) easy and works well.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;prerequisite&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Prerequisite&lt;/h1&gt;
&lt;p&gt;In order to follow this guide and upload your R code on GitHub, you will need at least:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a &lt;a href=&#34;https://github.com/&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt; account&lt;/li&gt;
&lt;li&gt;the &lt;a href=&#34;https://desktop.github.com/&#34; target=&#34;_blank&#34;&gt;GitHub Desktop&lt;/a&gt; application installed on your computer&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&#34;step-by-step-guide&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Step-by-step guide&lt;/h1&gt;
&lt;p&gt;For this guide, I use a R script created to plot the &lt;a href=&#34;https://statsandr.com/blog/covid-19-in-belgium-is-it-over-yet/&#34;&gt;evolution of the hospital admissions due to COVID-19 in Belgium&lt;/a&gt;. See the &lt;a href=&#34;https://github.com/AntoineSoetewey/COVID-19-Figures&#34; target=&#34;_blank&#34;&gt;repository on GitHub&lt;/a&gt; in case you want to see the final result before proceeding further.&lt;/p&gt;
&lt;p&gt;You often hear&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“A picture is worth a thousand words”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So here is without further ado how to upload your R script on GitHub in images:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-1.png&#34; alt=&#34;Step 1: Go to github.com/login and sign in&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 1: Go to github.com/login and sign in&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-2.png&#34; alt=&#34;Step 2: Go to your GitHub profile and create a new repository&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 2: Go to your GitHub profile and create a new repository&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-3.png&#34; alt=&#34;Step 3: Set the name, description, audience and README file for the new repository&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 3: Set the name, description, audience and README file for the new repository&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Be careful that if you choose to make it &lt;strong&gt;public&lt;/strong&gt;, it will be &lt;strong&gt;visible to everyone&lt;/strong&gt;. If you do not want to share the code, but still want it to be uploaded on GitHub, choose the private option.&lt;/p&gt;
&lt;p&gt;Initializing the repo with a README file is not mandatory, but I strongly recommend it so you will be able to add information for this repo.&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-4.png&#34; alt=&#34;Step 4: You now see your new repository with only the README file&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 4: You now see your new repository with only the README file&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-5.png&#34; alt=&#34;Step 5: Open the GitHub Desktop application and sign in with your GitHub account&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 5: Open the GitHub Desktop application and sign in with your GitHub account&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-6.png&#34; alt=&#34;Step 6 a: Clone the repository you just created on github.com to your computer&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 6 a: Clone the repository you just created on github.com to your computer&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-7.png&#34; alt=&#34;Step 6 b: Clone the repository you just created on github.com to your computer&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 6 b: Clone the repository you just created on github.com to your computer&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-8.png&#34; alt=&#34;Step 6 c: Clone the repository you just created on github.com to your computer&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 6 c: Clone the repository you just created on github.com to your computer&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-9.png&#34; alt=&#34;Step 7: Your new repo appears on the GitHub Desktop application&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 7: Your new repo appears on the GitHub Desktop application&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-10.png&#34; alt=&#34;Step 8: Open an R script and write your code&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 8: Open an R script and write your code&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;(See &lt;a href=&#34;https://statsandr.com/blog/how-to-install-r-and-rstudio/&#34;&gt;how to install R and RStudio&lt;/a&gt; if you are unfamiliar with it.)&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-11.png&#34; alt=&#34;Step 9 a: Save your R script in the corresponding folder&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 9 a: Save your R script in the corresponding folder&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You can see the path to the folder in step 6 c, under “Local Path”.&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-12.png&#34; alt=&#34;Step 9 b: Save your R script in the corresponding folder&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 9 b: Save your R script in the corresponding folder&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-13.png&#34; alt=&#34;Step 10: Reopen GitHub Desktop, edit the commit title (1) and click on the commit button (2)&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 10: Reopen GitHub Desktop, edit the commit title (1) and click on the commit button (2)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In step 10, make sure that the current repository (see top left) is the repo you are currently working on.&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-14.png&#34; alt=&#34;Step 11: Push the commit to github.com&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 11: Push the commit to github.com&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-15.png&#34; alt=&#34;Step 12: On your GitHub profile, click on the newly created repository&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 12: On your GitHub profile, click on the newly created repository&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-16.png&#34; alt=&#34;Step 13: You now see your script which has been added to the repository&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Step 13: You now see your script which has been added to the repository&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Your R code is now available online via the new repository on your GitHub profile. If you need to share it, you can simply share the URL of the repo.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;additional-notes&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Additional notes&lt;/h1&gt;
&lt;p&gt;If you need to edit your code:&lt;/p&gt;
&lt;ol style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;Find the folder of the repo on your computer by clicking on the button “Show in Finder”:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/find%20the%20repo%20on%20your%20computer.png&#34; style=&#34;width:100.0%&#34; alt=&#34;Find the folder of your repo on your computer&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Find the folder of your repo on your computer&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;2&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;You will be redirected to the folder of your repo on your computer. Open the R script you want to work on, edit it and save it:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-17.png&#34; alt=&#34;Open the R script, edit it and save it&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;Open the R script, edit it and save it&lt;/div&gt;
&lt;/div&gt;
&lt;ol start=&#34;3&#34; style=&#34;list-style-type: decimal&#34;&gt;
&lt;li&gt;After your script is saved, &lt;strong&gt;do not forget to commit the changes and push the commit&lt;/strong&gt; (see step 10 above).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In case you need to see an old version of your code, you can see all commits by clicking on the commits tab accessible via the repo on github.com:&lt;/p&gt;
&lt;div class=&#34;float&#34;&gt;
&lt;img src=&#34;https://statsandr.com/blog/2020-05-24-how-to-create-a-github-repository-for-r-scripts-on-macos_files/upload-r-code-on-GitHub-example-with-an-r-script-on-mac-os-18.png&#34; alt=&#34;See all commits&#34; /&gt;
&lt;div class=&#34;figcaption&#34;&gt;See all commits&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;conclusion&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;I hope this article helped you to create a GitHub repository, and upload your R scripts so that it is available to anyone.&lt;/p&gt;
&lt;p&gt;As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>