The packageSkeleton repository provides a comprehensive, production-ready template for creating professional R packages with integrated Quarto documentation websites. This skeleton eliminates the complexity of package setup by providing a fully configured development environment that includes automated testing, continuous integration, and professional documentation hostingβall ready to deploy on GitHub.
Transform your R scripts and workflows into a professional, shareable package in minutes rather than hours. Whether you're consolidating personal utilities, creating tools for your team, or contributing to the open-source community, this skeleton provides everything you need to get started immediately.
- Use this template: Click "Use this template" on GitHub or clone this repository
- Rename: Replace "packageSkeleton" with your package name throughout the project
- Customize: Add your functions to
R/
, updateDESCRIPTION
, and modify documentation - Deploy: Push to GitHub - your package website will automatically deploy via GitHub Pages
π Detailed Setup Guide | π Live Example
This skeleton provides a complete R package infrastructure:
packageSkeleton/
βββ R/ # Your R functions
βββ man/ # Auto-generated documentation
βββ vignettes/ # Package tutorials and examples
βββ tests/ # Automated testing framework
βββ data/ # Package datasets
βββ DESCRIPTION # Package metadata
βββ NAMESPACE # Package namespace (auto-managed)
βββ LICENSE.md # License information
βββ _quarto.yml # Website configuration
βββ index.qmd # Homepage content
βββ articles/ # Vignettes and tutorials
βββ reference/ # Function documentation
βββ .github/workflows/ # Automated deployment
- Automated Testing: Pre-configured
testthat
framework - CI/CD Pipeline: GitHub Actions for testing and deployment
- Code Coverage: Integrated coverage reporting
- Documentation: Automatic function documentation with
roxygen2
- Website Hosting: Automated Quarto website deployment to GitHub Pages
- Package Checks: Comprehensive R CMD CHECK validation
- Zero-Configuration Setup: Clone and start developing immediately
- Automated Documentation: Functions documented with roxygen2 are automatically included in your website
- Professional Styling: Clean, responsive Quarto website with modern design
- Continuous Integration: Automated testing on multiple R versions and operating systems
- Easy Customization: Modular structure allows easy modification of any component
- Version Control: Git-ready with appropriate
.gitignore
and configuration files - Cross-Platform: Works seamlessly on Windows, macOS, and Linux
- Personal Utility Libraries: Consolidate your frequently-used data cleaning, visualization, and analysis functions
- Workflow Automation: Package repetitive tasks into reusable functions with professional documentation
- Team Collaboration: Share standardized tools and methodologies across your organization
- Package Prototyping: Quickly test and iterate on package ideas with full infrastructure
- Best Practices: Learn modern R package development through a well-structured example
- Portfolio Projects: Create professional showcases of your R capabilities
- Course Materials: Package datasets, functions, and tutorials for students
- Research Tools: Share reproducible analysis tools with the scientific community
- Workshop Resources: Provide participants with ready-to-use packages and documentation
- R (β₯ 4.0.0) and RStudio (recommended)
- Git for version control
- GitHub account for hosting and collaboration
- Basic familiarity with R package structure
Install these packages to fully utilize the skeleton:
# Core development tools
install.packages(c("devtools", "usethis", "roxygen2", "testthat"))
# Documentation and website
install.packages(c("quarto", "pkgdown"))
-
Create your repository:
- Click "Use this template" on the GitHub repository page
- Name your new repository (e.g., "myAwesomePackage")
- Clone to your local machine
-
Customize the package:
# In RStudio, open the project and run: usethis::use_description(fields = list( Title = "Your Package Title", Description = "What your package does", `Authors@R` = "Your Name <[email protected]> [aut, cre]" ))
-
Add your content:
- Place R functions in
R/
directory - Add datasets to
data/
directory - Create vignettes in
vignettes/
directory - Write tests in
tests/testthat/
directory
- Place R functions in
-
Build and check:
# Document functions and build package devtools::document() devtools::check() # Build website locally quarto::quarto_render()
-
Deploy:
- Push changes to GitHub
- Enable GitHub Pages in repository settings
- Your website will be available at
https://yourusername.github.io/yourpackage
Transform your R work into a professional package:
# Example: Custom data cleaning functions
clean_survey_data <- function(df, remove_incomplete = TRUE) {
# Your data cleaning logic here
}
# Example: Simplified statistical analysis
quick_regression <- function(data, outcome, predictors) {
# Wrapper for common regression tasks
}
# Example: Themed plotting functions
theme_publication <- function() {
# Custom ggplot2 theme for publications
}
- Finance: Portfolio analysis, risk calculations
- Education: Assessment scoring, growth modeling
- Healthcare: Clinical data processing, outcome analysis
- Marketing: Customer segmentation, campaign analysis
The skeleton includes a comprehensive testing framework:
# Example test structure in tests/testthat/
test_that("my_function works correctly", {
expect_equal(my_function(2, 3), 5)
expect_error(my_function("a", "b"))
})
Leverage roxygen2 for professional documentation:
#' Calculate Summary Statistics
#'
#' This function calculates descriptive statistics for a numeric vector.
#'
#' @param x A numeric vector
#' @param na.rm Logical, should NA values be removed?
#' @return A list of summary statistics
#' @examples
#' calc_summary(c(1, 2, 3, 4, 5))
#' @export
calc_summary <- function(x, na.rm = TRUE) {
# Function implementation
}
Modify _quarto.yml
to customize your site:
website:
title: "Your Package Name"
navbar:
left:
- text: "Home"
file: index.qmd
- text: "Reference"
file: reference/index.qmd
Creating an R package isn't just for CRAN submissionsβit's about building better tools for yourself and your team:
- Efficiency: Stop copying functions between projects
- Documentation: Force yourself to document your work properly
- Testing: Ensure your functions work correctly across different scenarios
- Sharing: Easily distribute your tools to colleagues and collaborators
- Portfolio: Demonstrate your R skills professionally
- Learning: Master R package development best practices
- π Complete Setup Guide: Step-by-step instructions
- π R Packages Book: Comprehensive guide by Hadley Wickham
- π Quarto Documentation: Learn to customize your website
- π GitHub Actions: Understand the CI/CD pipeline
- Issues: Report bugs or request features via GitHub Issues
- Discussions: Ask questions and share ideas in GitHub Discussions
- Contributing: Pull requests welcome! See
CONTRIBUTING.md
for guidelines - Community: Join the broader R package development community
Ready to start building? Use this template and create your first R package today! π
Produced with love β€οΈβ€οΈβ€οΈοΈ by: