A presentation about R project structures. It includes a basic template along with some extensions that should cover most cases. For the more advanced users, the presentation also mentions some practices such as version control and containerization.
You can run the project in RStudio by following these steps:
- Open RStudio
- Click on "File" and then "New Project..." on the top bar. A window will open
- Select "Version Control" and then "Git"
- Paste "https://github.com/GiuseppeTT/R-Project-Structure" in the "Repository URL" field, select the parent directory of the project in "Create project as a subdirectory of" and then click on "Create Project"
- Wait for the project to be created
- Paste and execute the following commands in the R console:
install.packages("devtools")devtools::install_deps(dependencies = TRUE)devtools::document()devtools::install()
- After everying, run the
render.Rscript
You can run the project inside a development container by following these steps in the VSCode code editor:
- Open VSCode
- Install the Remote - Containers extension
- Open the command palette (press
F1key), select the command "Git: Clone" and clone this repository https://github.com/GiuseppeTT/R-Project-Structure.git - Open the command palette (press
F1key) and select the command "Remote-Containers: Open Folder in Container..." - Open a new terminal (press
ctrl+shift+`) and execute the commandRscript render.R
After that, the presentation will be available at output/github-pages/presentation.html.
Notes: you may need to install docker.
You can run the project by executing the following commands in the terminal:
git clone https://github.com/GiuseppeTT/R-Project-Structure.git # Clone project
cd R-Project-Structure # Access project directory
Rscript -e "install.packages('devtools')" # Install {devtools}
Rscript -e "devtools::install_deps(dependencies = TRUE)" # Install R packages
Rscript -e "devtools::document(); devtools::install()" # Install project package
Rscript render.R # Render presentationAfter that, the presentation will be available at output/github-pages/presentation.html.
Notes: you may need to install the system package libcurl. You can do that on Ubuntu with the command sudo apt-get install libcurl4-openssl-dev.
If you are a contributor to this repository, every time you push to the main branch, the deploy workflow will render and deploy the presentation to the repository's GitHub Page.
The render.R script is the main entrypoint.
Project structure:
.devcontainer/: VSCode Remote-Container files. Used for development inside a container.github/: GitHub Action files. Used for CI/CDdata/: Data filesexample/: Examples of projects that follow the proposed project structuresextra/: Extra, non-code, filesman/: R documentation files. Ignored by gitoutput/: Output files. The presentation html file used by GitHub Pages is hereR/: R Project package functionsRmd/: Rmd files. The presentation Rmd file is here.gitignore: List files that git should ignore.lintr:{lintr}files. Used for linting.Rbuildignore: List files that R project package should ignore during buildingDESCRIPTION: R project package meta fileLICENSE: License filemakefile: List useful commands. You can use them on terminal withmake <command_name>NAMESPACE: R project package exports. Ignored by gitREADME.md: Must read file. This very file you are readingrender.R: Run this script to render the presentation