Skip to content

DevonAllies/template

Repository files navigation

template

This repository offers a robust Quarto template designed for reproducible research and academic writing. It leverages the power of both R and Python for data manipulation, analysis, and visualization, with renv ensuring a fully reproducible R environment and clear directory structures for organized data and figures.


Prerequisites

Before attempting to render this document or use the template, ensure that the following software and packages are installed on your system:

1. R:

  • Make sure you have R installed (version 4.0 or newer is recommended). You can download it from The Comprehensive R Archive Network (CRAN).
  • RStudio Desktop is highly recommended as an Integrated Development Environment (IDE) for seamless R and Quarto development. Download it from Posit.

2. R Packages (Managed by renv):

This project uses renv to ensure a fully reproducible R environment. All necessary R packages and their exact versions are locked down in the renv.lock file. Key packages include:

  • tidyverse: A collection of R packages designed for data science, including dplyr for data manipulation and ggplot2 for data visualization.
  • reticulate: Provides essential tools for seamless interoperability between R and Python.
  • scales: Offers functions for numeric and color scales, useful for plots.
  • readxl: Enables efficient reading of data from Excel files.
  • here: Crucial for constructing file paths relative to the project root, ensuring your code works consistently.

3. Python:

  • Make sure you have Python installed (version 3.8 or newer is recommended). Using a distribution like Anaconda is highly recommended as it simplifies package and environment management for scientific libraries.

4. Python Packages:

The following Python packages are required and will be automatically installed by reticulate (from within your Quarto document) if not found in your active Python environment:

  • numpy: The fundamental package for numerical computation in Python.
  • pandas: Provides powerful data structures and data analysis tools.
  • seaborn: A high-level data visualization library based on Matplotlib.
  • matplotlib: A comprehensive library for creating static, interactive, and animated visualizations in Python.
  • statsmodels: Offers classes and functions for the estimation of various statistical models, tests, and data exploration.
  • scienceplots: A collection of scientific plotting styles for Matplotlib.

5. Quarto:


Installation & Usage

To generate the template.pdf and begin working with this project, follow these steps:

  1. Clone the repository: Open your terminal or command prompt and run:

    git clone [https://github.com/DevonAllies/template.git](https://github.com/DevonAllies/template.git)
    cd template
  2. Set up the R environment using renv:

    • Open the template.Rproj file (or simply open the template directory) in RStudio.
    • renv will automatically activate when you open the project. You'll likely see a prompt in the R console suggesting you run renv::restore().
    • Run renv::restore() in the R console. This vital step downloads and installs all necessary R packages at the exact versions specified in the renv.lock file, ensuring a reproducible R environment.
  3. Render the document:

    • With your R and Python environments set up and activated, navigate to the project root directory (where template.qmd is located) in your terminal or command prompt.
    • Run the Quarto render command:
      quarto render template.qmd
    • This command executes the R and Python code chunks, generating template.pdf (and potentially template.docx if configured), which will be saved in the output/ directory as configured by your _quarto.yml file.

Acknowledgement

  • This template was built using resources from Stellenbosch University.

About

A python & R template

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published