This file contains comprehensive instructions for GitHub Copilot to effectively work with the bregr R package repository.
The bregr package is an R package for easy and efficient batch processing of regression models. It provides tools for running univariate and multivariate regression models in batch, returning results in tidy format with visualization capabilities.
- Type: Standard R package
- Language: R (>= 4.1.0)
- Testing: testthat framework
- Documentation: roxygen2 + pkgdown
- CI/CD: GitHub Actions with R-CMD-check
- Dependencies: tidyverse ecosystem, statistical modeling packages
R/: Core R functions for batch regression modelingtests/testthat/: Unit tests and example testsman/: Auto-generated documentation filesvignettes/: Package vignettes and tutorialsdata-raw/: Raw data processing scriptsDESCRIPTION: Package metadata and dependencies
Use the modern R installation manager rig and package installer pak for optimal development experience:
# Install rig (R Installation Manager)
curl -Ls https://github.com/r-lib/rig/releases/download/latest/rig-linux-latest.tar.gz | sudo tar xz -C /usr/local
# Install latest R release
sudo rig add release
# Verify installation
rig list
R --versionTiming: rig installation ~1 minute, R installation ~5-8 minutes
# Navigate to package directory
cd /path/to/bregr
# Install all package dependencies using pak (much faster than install.packages)
R --slave -e "pak::local_install_deps()"
# Install additional development tools
R --slave -e "pak::pak(c('knitr', 'rmarkdown', 'testthat', 'pkgdown'))"Timing: Dependencies installation ~4-6 minutes, dev tools ~2-3 minutes
Essential system packages (automatically handled by pak):
pandoc(for vignettes and documentation)libxml2-dev,libcurl4-openssl-dev,libssl-dev(for various R packages)- Graphics libraries:
libfreetype6-dev,libjpeg-dev,libpng-dev,libtiff-dev
# Quick build (without vignettes) - recommended for development
R CMD build . --no-build-vignettes
# Full build (with vignettes) - for release
R CMD build .Timing: Quick build ~10-20 seconds, Full build ~5-10 minutes
# Quick check (skip suggested packages)
_R_CHECK_FORCE_SUGGESTS_=false R CMD check package_*.tar.gz --no-manual
# Full check (requires all suggested packages)
R CMD check package_*.tar.gz --no-manualTiming: Quick check ~2-3 minutes, Full check ~10-15 minutes
# Install package locally first
R --slave -e "pak::local_install('.')"
# Run tests
R --slave -e "testthat::test_dir('tests/testthat')"
# Test basic functionality
R --slave -e "library(bregr); mtcars_result <- br_pipeline(mtcars[1:10,], y='mpg', x=c('cyl','disp'), method='gaussian'); print('Success!')"Timing: Local install ~10-15 seconds, Tests ~30-60 seconds
# Build pkgdown site
R --slave -e "pkgdown::build_site()"
# Update documentation
R --slave -e "devtools::document()"Timing: pkgdown build ~2-5 minutes, documentation update ~30 seconds
br_pipeline(): Main function for batch regression modelingbr_show_*(): Visualization functions (forest plots, tables, networks)- Support for multiple regression methods: gaussian, binomial, cox, etc.
- Tidy output format compatible with broom ecosystem
- Linear regression (
gaussian) - Logistic regression (
binomial) - Cox proportional hazards (
coxph) - Poisson regression (
poisson) - And more (see vignettes for full list)
library(bregr)
# Simple linear regression example
result <- br_pipeline(
data = mtcars,
y = "mpg",
x = c("cyl", "disp", "hp"),
method = "gaussian"
)
# Visualize results
br_show_forest(result)
br_show_table(result)- Edit R functions in
R/directory - Update documentation with roxygen2 comments
- Run
devtools::document()to update man files - Test changes with
testthat::test_dir('tests/testthat') - Build and check package with
R CMD buildandR CMD check
- Create function in appropriate R file in
R/directory - Add roxygen2 documentation with
@exportif public function - Add unit tests in
tests/testthat/ - Update
NAMESPACEwithdevtools::document() - Consider adding examples to vignettes if it's a major feature
- Use
pakinstead ofinstall.packages()for faster package management - Skip vignette building during development iterations
- Use
_R_CHECK_FORCE_SUGGESTS_=falsefor faster checking - Use
_R_CHECK_DEPENDS_ONLY_=truefor depends checking - Consider parallel testing for large test suites
- Vignette build failures: Often due to missing suggested packages, build without vignettes for development
- Dependency conflicts: Use
pak::pak_sitrep()to diagnose issues - System library missing: pak will usually install automatically, but check error messages
- Package not found errors: Make sure to install package locally with
pak::local_install('.') - Suggested package errors: Install missing packages or use
_R_CHECK_FORCE_SUGGESTS_=false
- Missing exports: Add
@exportto roxygen2 comments and rundevtools::document() - Cross-reference errors: Check that referenced packages are available
- rig setup: ~1 minute
- R installation: ~5-8 minutes
- Package dependencies: ~4-6 minutes
- Quick build: ~10-20 seconds
- Quick check: ~2-3 minutes
- Local install: ~10-15 seconds
- Test suite: ~30-60 seconds
- pkgdown build: ~2-5 minutes
- Full check: ~10-15 minutes
- Full build with vignettes: ~5-10 minutes
- Use rig and pak: Modern, faster alternatives to traditional R installation and package management
- Incremental development: Use quick builds and checks during development
- Test early and often: Install locally and test after each significant change
- Documentation-driven development: Keep roxygen2 comments up to date
- Leverage CI/CD: Let GitHub Actions handle full checks for pull requests
- Version control: Use meaningful commit messages and atomic commits
# Update pak
R --slave -e "pak::pak_update()"
# Clear pak cache
R --slave -e "pak::cache_clean()"
# Check pak status
R --slave -e "pak::pak_sitrep()"# List installed R versions
rig list
# Switch R version if needed
rig default 4.5.1
# Check R configuration
R --slave -e "sessionInfo()"This setup provides a modern, efficient development environment for the bregr R package using best practices and contemporary tools.