# fastrda: Fast Redundancy Analysis (RDA) with HPC C++ Backend

**fastrda** is a high-performance implementation of Redundancy Analysis (RDA) for R, 
written in C++ using Armadillo and OpenMP. It is designed for ecological, genomic, and 
other large multivariate datasets where computational efficiency is critical.
<img src="man/figures/fastrdalogo.png" alt="fastrda" width="200" style="float: right; margin-left: 15px;"/>

## Features

- High-performance C++ backend using Armadillo
- OpenMP parallel computation
- Standard and partial redundancy analysis (RDA)
- Parallel permutation tests (`anova()` and `anova_fastrda()`)
- Prediction for new observations
- Multiple score scaling options
- Memory-efficient workspace modes
- Publication-ready biplots
- Familiar S3 interface (`print()`, `summary()`, `predict()`, `scores()`, `plot()`, `biplot()`)

---

## Installation

### CRAN

```r
install.packages("fastrda")
```
---

## Quick Example

```r
library(fastrda)
library(vegan)

data(mite, mite.env)

# Hellinger transformation
Y <- decostand(mite, "hellinger")

# Environmental variables
X <- model.matrix(~ SubsDens + WatrCont, mite.env)[, -1]

fit <- fastrda(
  genotype = Y,
  environment = X,
  axes = 2,
  keep_workspace = "minimal"
)

summary(fit)

# Ordination plot
plot(fit)
```

### Permutation test

```r
anova(fit, permutations = 999)
```

### Direct biplot

```r
biplotrda(fit)
```

---

## Workspace Modes

| Mode | Recommended use |
|------|------------------|
| `"minimal"` | Permutation testing (recommended default) |
| `"compact"` | Prediction for new data |
| `"full"` | Prediction and permutation testing |
| `"none"` | Lowest memory usage |

---

## Documentation

The package vignette contains a complete workflow and additional examples.

```r
vignette("fastrda")
```

Browse all available documentation:

```r
help(package = "fastrda")
```

or

```r
browseVignettes("fastrda")
```

---

## Performance

Internal benchmarks on synthetic datasets containing up to 10,000 response variables showed median speedups of approximately **100×** while maintaining numerical accuracy.

---

## License

GPL (>= 3)