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.
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, includingdplyr
for data manipulation andggplot2
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:
- Make sure you have Quarto installed. Find detailed installation instructions at https://quarto.org/docs/install/.
To generate the template.pdf
and begin working with this project, follow these steps:
-
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
-
Set up the R environment using
renv
:- Open the
template.Rproj
file (or simply open thetemplate
directory) in RStudio. renv
will automatically activate when you open the project. You'll likely see a prompt in the R console suggesting you runrenv::restore()
.- Run
renv::restore()
in the R console. This vital step downloads and installs all necessary R packages at the exact versions specified in therenv.lock
file, ensuring a reproducible R environment.
- Open the
-
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 potentiallytemplate.docx
if configured), which will be saved in theoutput/
directory as configured by your_quarto.yml
file.
- With your R and Python environments set up and activated, navigate to the project root directory (where
- This template was built using resources from Stellenbosch University.