Nate Thomas, NH Occupational Health Surveillance Program | Institute on Disability, University of New Hampshire
12 October 2023
Demonstrate:
the benefits of utilizing github as a file retention, collaboration, and version control toolset.
a quick How-To, to set up github and utilize it within RStudio.
Disclaimer: This is only intended for familiarization purposes - github’s functionality and use far exceeds what I’ll be able to go over here. I’m not affilidated with Github in any way.
Have you ever updated a file, and regretted it - wishing you could revert back to a previous version? - I mash Ctrl+S continuously during file/document updates as a matter of course… but sometimes I wish I hadn’t.
Are your analysis files stored in a less than easy to use and unintuitive C:/users/[username]/Documents folder, like a filing cabinet without folders? Sometimes if one is just “doing this one thing quickly” and lax about keeping files rigorously organized you can really put yourself in a bind - if you have to then update it.
Do you have to pick up analysis from projects months, even years later - and have a hard time remembering where you were at in the process? Long term memory should be reserved for your important moments in life… project status shouldn’t have to be something you need to keep track of…
Github provides a free (with limitations) version control and collaboration system.
Repository (Repo) - a github project container.
Fetch - retrieve new work by others using the repo.
Merge - combine fetched work with your local work.
Pull - Fetch and Merge combined (run at the same time).
Push - Send local work to the repo.
Clone - clones a repo to your local computer.
Every github repo has a unique URL - this exact project is here: https://github.com/unh-iod/CSTE_github_demonstration
My personal preference is to use Github within the RStudio integrated development environment (IDE). This isn’t just for people using R as their prefered scripting language.
Example dataset (class) from SAS from the sashelp library
proc means data=sashelp.class;
output out=temp;
run;
proc export data=temp
outfile="sas_data.csv"
dbms=csv
replace;
run;
The MEANS Procedure
Variable N Mean Std Dev Minimum Maximum
-------------------------------------------------------------------------
Age 19 13.3157895 1.4926722 11.0000000 16.0000000
Height 19 62.3368421 5.1270752 51.3000000 72.0000000
Weight 19 100.0263158 22.7739335 50.5000000 150.0000000
-------------------------------------------------------------------------
X_TYPE_ | X_FREQ_ | X_STAT_ | Age | Height | Weight |
|---|---|---|---|---|---|
0 | 19 | N | 19.000000 | 19.000000 | 19.00000 |
0 | 19 | MIN | 11.000000 | 51.300000 | 50.50000 |
0 | 19 | MAX | 16.000000 | 72.000000 | 150.00000 |
0 | 19 | MEAN | 13.315789 | 62.336842 | 100.02632 |
0 | 19 | STD | 1.492672 | 5.127075 | 22.77393 |
Source: https://resources.github.com/github-and-rstudio/
Download and install Git
Download and install RStudio. (1.1.383 or higher).
Create a remote repository on Github:
>
>
This how you update files already in the repo:
Save the file locally.
Commit the changes:
Adding github users is as easy as adding them here.
An email invitation will be sent to the prospective collaborator - and they will be able to then accept the invitation and work on the repo.
Select Git > Commit and click
Enter file names for files that should only be stored locally (ignored by the repo)
https://github.com/unh-iod/CSTE_github_demonstration
If you clone this repo file which generates the entire presentation is “demonstration.Rmd”
Install any libraries required by
Click Knit…
https://resources.github.com/github-and-rstudio/
Install RStudio: https://posit.co/download/rstudio-desktop/
Github quickstart: https://docs.github.com/en/get-started/quickstart/hello-world