Lecture notes based on https://miguelhernan.org/whatifbook
This repository serves two purposes:
- R Package: Structured as an R package for easy installation and distribution
- Quarto Website: Contains lecture notes, slides, and handouts in multiple formats
To install this package from GitHub:
# Install devtools if not already installed
install.packages("devtools")
# Install the win package
devtools::install_github("ucdavis/win")The package uses renv for dependency management. After cloning the repository, restore dependencies with:
# Install renv if not already installed
install.packages("renv")
# Restore package dependencies from renv.lock
renv::restore()This Quarto website project is configured to render each chapter in multiple formats:
- HTML Website: Traditional website layout with navigation navbar
- RevealJS Slides Format: Presentation slides for each chapter
- PDF Handouts: PDF documents for each chapter
- DOCX Documents: Microsoft Word format documents for each chapter
The project uses Quarto's multi-format rendering capability with profile-based configuration:
- Default profile: website (generates HTML, RevealJS, PDF, and DOCX in
_site/) - RevealJS profile: standalone slides rendering (generates slides in
_slides/) - Handout profile: standalone PDF rendering (generates PDFs in
_handouts/)
_quarto.yml: Main configuration file with shared settings and default profile_quarto-website.yml: Website configuration with HTML, RevealJS, PDF, and DOCX formats_quarto-revealjs.yml: Standalone RevealJS slides configuration_quarto-handout.yml: Standalone PDF handouts configurationindex.qmd: Website homepagechapters/: Directory containing chapter filesstyles.css: Custom CSS for the HTML format
Note: PDF rendering requires TinyTeX to be installed. If you don't have TinyTeX installed, you can:
- Install it with:
quarto install tinytex --no-prompt - Or skip PDF rendering by using
--to html,revealjs,docxflag
To render the default website with all formats (HTML, RevealJS, PDF, and DOCX):
quarto renderThis will generate in _site/ directory:
- HTML pages:
index.html,chapters/01-introduction.html, etc. - RevealJS slides:
index-slides.html,chapters/01-introduction-slides.html, etc. - PDF handouts:
index-handout.pdf,chapters/01-introduction-handout.pdf, etc. (requires TinyTeX) - DOCX documents:
index.docx,chapters/01-introduction.docx, etc.
To render without PDF:
quarto render --to html,revealjs,docxTo render only slides:
QUARTO_PROFILE=revealjs quarto renderTo render only PDF handouts:
QUARTO_PROFILE=handout quarto renderEach chapter uses conditional content blocks to provide format-specific content:
::: {.content-visible when-format="html"}
Detailed content for website format
:::
::: {.content-visible when-format="revealjs"}
Concise content for slides
:::This allows the same source file to generate comprehensive HTML pages, focused presentation slides, PDF handouts, and DOCX documents.
This repository is structured as a standard R package:
DESCRIPTION: Package metadata and dependenciesNAMESPACE: Package namespace (managed by roxygen2)R/: R source code filesman/: Documentation files (generated by roxygen2)LICENSE: MIT license file.Rbuildignore: Files to exclude from package buildswin.Rproj: RStudio project configuration with package build settings
The Quarto website components (chapters, configuration files, etc.) are excluded from the R package build via .Rbuildignore, allowing the repository to function both as a package and as a Quarto website project.
When working on this repository in RStudio, the project is configured with:
- Build type: Package
- Package development tools enabled
- Code indexing for better navigation
- UTF-8 encoding
- 2 spaces for tabs (following tidyverse style)
This repository includes comprehensive GitHub Copilot instructions in .github/copilot-instructions.md to help Copilot provide better assistance with:
- Project-specific development setup and workflows
- Quarto multi-format rendering requirements
- R package structure and conventions
- Build, test, and lint commands
- Common issues and solutions
Copilot will automatically use these instructions when working on this repository.
To build and check the package:
# Build the package
devtools::build()
# Check the package
devtools::check()
# Generate documentation
devtools::document()