Introduction
Content
This section covers the following topics:
- Setting up a folder structure
- Using git for version control
- Publishing your project on GitHub
- Choosing a license
Project Setup
If you do not have any code of your own to work with, fork the repository here to get started.
Research compendium
A research compendium is a collection of all digital parts of a research project including data, code, texts (…). The collection is created in such a way that reproducing all results is straightforward.
Source: The Turing Way
Getting started
Contain your project in a single recognizable folder
Distinguish folder types, name them accordingly:
- Read-only: data, metadata
- Human-generated: code, paper, documentation
- Project-generated: clean data, figures, models…
Initialize a README file, document your project
Choose a license
Publish your project.
Getting started
.
├── README.md
├── code
│ ├── clean.R
│ ├── figures.R
├── data
├── documents
│ ├── documentation
│ ├── manuscript
└── output
├── figures
└── tables
Getting Started with Our Project
Creating a well-organized project is crucial for reproducibility. Here’s how to set up your project in RStudio and the benefits of using an .Rproj
file.
Step-by-Step Guide for Setting Up an R Project in RStudio
Open RStudio.
Create a New Project:
- Go to File > New Project in RStudio.
- Choose New Directory, then select New Project.
- Name the Project: Give it a recognizable name based on your research topic.
- Location: Choose or create a directory to store your project.
- Initialize Git: If prompted, check Create a Git repository to set up version control right from the start (or this can be added later).
- Click Create Project.
Set Up a Project Folder Structure:
Here’s a sample structure, but feel free to adapt it to suit your needs. Think about where your code, data, outputs, and documentation will be stored.
.
├── README.md
├── code
│ ├── clean.R
│ ├── figures.R
├── data
├── documents
│ ├── documentation
│ ├── manuscript
└── output
├── figures
└── tables
- Write a
README.md
File: This file introduces your project. Include the purpose, structure, and instructions for reproducing results. It’s the first thing collaborators or reviewers should read!
Benefits of an .Rproj
File
An .Rproj
file is automatically created when you start a new R Project. This file has several important benefits:
- Project-Specific Settings: It allows you to set options specific to this project (e.g., Git integration, default working directory).
- Easy Access: Acts as a shortcut to open your project directly from the filesystem, ensuring you’re always in the correct working directory.
- Consistency Across Computers: Loads the project’s configuration consistently, so anyone opening the
.Rproj
file will see the same setup. - Keeps Temporary Files Separate: Stores temporary files (like auto-saved scripts) in a hidden
.Rproj.user
folder, which is ignored by Git.
Note on Folder Structure
Your compendium structure doesn’t need to look exactly like this! Adapt the folders to fit your specific project needs, such as adding a functions
folder for custom functions or subfolders within data
for different data sources.
Reproducibility
Emphasizing computational reproducibility, we’ll employ version control using Git and GitHub. This approach not only ensures that our work can be reliably replicated by others but also facilitates collaboration among researchers.
➡️ Exercise
Time for some hands-on practice!
Be sure to ask for help when you need it!
1. Version Control with Git and GitHub
Initializing a Git Repository
Navigate to your project directory in the terminal:
git init
Creating a Remote Repository on GitHub
On GitHub, create a new repository with the same name as the one that you just created locally. Link your local repository to this remote:
git remote add origin [your-repository-url]
Pushing to GitHub
Commit and push your changes:
git add .
git commit -m "Initial commit"
git push --set-upstream origin main
Experimenting with GitHub
Make edits directly on GitHub and then pull those changes:
git pull
2. Publication & Licensing
Reviewing Your License
Create a LICENSE.md
file in your project directory.
touch LICENSE.md
Exploring Licensing Options
Visit choosealicense.com for other options. Update the LICENSE.md
file and push to GitHub!: