-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
86 lines (60 loc) · 4.86 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# Reproducible code using git and GitHub
This tutorial covers version control with git. The tutorial is meant to be hands-on, so the target audience should have access to a PC (preferably Windows) with an internet connection. One must also install Git for Windows (v2.31.1 or higher), and an active R/R Studio environment.
We will begin with a brief introduction to the concepts of git and then move on to some hands-on learning (no prior experience needed). At the end of the meeting, you will know how to create a repository, commit changes, and push/pull changes from a remote repository.
To support the reproducibility of these analyses, this tutorial employs literate programming using [Rmarkdown(Rmd)](https://rmarkdown.rstudio.com/) and full R package dependency management using the [renv](https://rstudio.github.io/renv/articles/renv.html) package.
## Prerequisites:
### Hardware:
* A computer with an internet connection
### Software:
* Register a GitHub Account: [https://github.com](https://github.com)
* Install [Git for Windows v2.31.1 64-bit](https://git-scm.com/download/win) also known as msysgit or “Git Bash”, to get Git in addition to some other useful tools, such as the Bash shell. Yes, all those names are totally confusing, but you might encounter them elsewhere and I want you to be well-informed.
* NOTE: When asked about “Adjusting your PATH environment”, make sure to select “Git from the command line and also from 3rd-party software”. Otherwise, we believe it is good to accept the defaults.
#### Configure git user info:
* Introduce yourself to Git using Git Bash (included with Git for Windows).
In the shell, configure your global user name and user email (associated with your github account):
```{bash echo=T, results='hide', eval=F}
git config --global user.name 'Jane Doe'
git config --global user.email '[email protected]'
git config --global --list
```
* For additional instructions, see: [https://happygitwithr.com/hello-git.html](https://happygitwithr.com/hello-git.html)
* (Optional) Install a Git client. Learning version control (e.g. git) is much easier with the use of a GUI, which is frequently called a git client. My favorite client for windows is [Sourcetree](https://www.sourcetreeapp.com/).
* For additional info, see: [https://happygitwithr.com/git-client.html](https://happygitwithr.com/git-client.html).
During our meeting I will (likely) give a brief demo using Sourcetree and RStudio, which is nicely integrated with git, and is the primary interface I personally use.
## Hands On Demo:
### To run R/RStudio locally:
* Install [R version 4.0.0 or above](https://www.r-project.org/)
* Install [RStudio Desktop 1.2 or above](https://rstudio.com/products/rstudio/)
### Running the test analysis:
This tutorial includes a very simple analysis, executed in 2 .Rmd scripts. In [1.02_Hello-World.Rmd](Scripts/1.02_Hello-World.Rmd) which reads in an excel spreadsheet and outputs the contents of that spreadsheet to a .txt file. In [2.02_PCA-example.Rmd](Scripts/2.02_PCA-example.Rmd), we run a simple PCA analysis of the mtcars dataset.
After cloning this repo, the first required step is to install the R dependencies required to run the analysis (written in the .Rmd files in R_scripts). To do so, execute the following command in your R environment.
```{r eval=FALSE, message=FALSE, warning=FALSE}
renv::restore()
```
This will automatically install the packages required to run this analysis. By doing this, one will be able to execute the analysis using the same R packages (and the same versions) each time. Note that this will only need to be run once.
#### Mechanics:
To run this analysis, first create/clean the results output folder by running the codes in [95_Make_Clean.Rmd](). Subsequently, run the code chunks in [99_Run_All.Rmd](R_scripts/99_Run_All.Rmd). This will run the Rmarkdown (.Rmd) files containing the actual code for this analysis in numerical order.
Running [99_Run_All.Rmd](R_scripts/99_Run_All.Rmd) will also render html files of each .Rmd file, which will be saved to the results folder, making useful reports of this analysis. Finally, this README.Rmd files will also be "knit" to an html file, as well as a markdown (.md) file, in the working directory of this repository. This markdown file makes for easy viewing on GitHub, and acts as the "home page" for this repo.
#### Output:
The resulting output files were saved to the [Results](Results) folder in this repository.
```{r echo=FALSE}
list.files(path="Results")
```
## Background slides:
* [Slides for Git Training Session](Presentations/An_Intro_to_Git.pptx) (includes presentation on git concepts)
## Session information
```{r session_info}
sessionInfo()
```
This document was processed on: `r Sys.Date()`.