This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
multivarious is an R package that provides extensible data structures for multivariate analysis, focusing on dimensionality reduction techniques and projection methods. The package implements a flexible framework built around the concept of "projectors" - objects that map high-dimensional data to lower-dimensional representations.
# From R console
devtools::install() # Build and install the package
devtools::build() # Build package tarball
devtools::load_all() # Load all functions for development
# From command line
R CMD build . # Build package
R CMD INSTALL . # Install package
# From R console
devtools::test() # Run all tests
testthat::test_package("multivarious") # Run tests directly
covr::package_coverage() # Run tests with coverage
# Run a single test file
testthat::test_file("tests/testthat/test_pca.R")
# From command line
R CMD check . # Run full package checks including tests
# Generate/update documentation from roxygen2 comments
devtools::document()
# Run package checks
devtools::check() # Full package check
R CMD check --as-cran . # CRAN-style checks
rcmdcheck::rcmdcheck() # Enhanced checking
# Build package website
pkgdown::build_site()
The package is built around a hierarchical system of projector classes:
projector
- Base class for all dimensionality reduction methodsv
for projectionpreproc
)Implements caching for performance (.cache
environment)
bi_projector
- Extends projector for two-way mappings (e.g., PCA, SVD)
s
and standard deviations sdev
Supports both row and column projections
cross_projector
- For two-block methods (e.g., CCA)
Enables cross-domain transfer operations
composed_projector
- Chains multiple projectors sequentially
multiblock_projector
- Handles concatenated blocks of variables
S3 Generic Functions: All major operations (project
, reconstruct
, truncate
, etc.) are implemented as S3 generics with method dispatch
Preprocessing Pipeline: Sophisticated preprocessing system where each step has forward()
, apply()
, and reverse()
methods
Caching Strategy: Expensive computations (inverse projections, etc.) are cached in each projector's .cache
environment
Partial Operations: Framework supports projecting/reconstructing subsets of variables via partial_project()
and related functions
chk::chk_*
functions for input validationrlang::abort()
Tests use testthat and follow these patterns:
- Test files are named test_<component>.R
- Use expect_equal()
with tolerance for numeric comparisons
- Test both standard and edge cases (empty data, single observation, etc.)
- Verify that preprocessing is correctly reversed
- Check that caching doesn't affect results
When adding a new projector type:
1. Inherit from appropriate base class (projector
, bi_projector
, etc.)
2. Implement required methods (project
, reconstruct
, etc.)
3. Add appropriate S3 method implementations in relevant files
4. Include input validation using chk
package
5. Add comprehensive tests
6. Update documentation with examples
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.