Skip to content

Commit 3fdc365

Browse files
Port improvements from statsExpressions v1.7.3
## Changes ### New Files - Add `.github/copilot-instructions.md` with package-specific guidance ### Dependency Updates (in DESCRIPTION) - statsExpressions: >= 1.7.2 -> >= 1.7.3 - dplyr: >= 1.1.4 -> >= 1.2.0 - ggplot2: >= 4.0.1 -> >= 4.0.2 - insight: >= 1.4.3 -> >= 1.4.6 - paletteer: >= 1.6.0 -> >= 1.7.0 - performance: >= 0.15.3 -> >= 0.16.0 - purrr: >= 1.2.0 -> >= 1.2.1 - rlang: >= 1.1.6 -> >= 1.1.7 - tidyr: >= 1.3.1 -> >= 1.3.2 - testthat: >= 3.3.0 -> >= 3.3.2 ### GitHub Workflows - Remove `r-version: "devel"` from check-no-warnings, html-5-check, pkgdown - Update actions/setup-python from v6.1.0 to v6.2.0 in pre-commit - Update test-coverage.yaml to display percentage and enforce 100% coverage ### Code Coverage - Update codecov.yaml to enforce 100% coverage (target: 100%, threshold: 0%) ### Accessibility - Add alt text to images in README.Rmd - Add fig.alt attributes to all code chunks with figures Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b6621e3 commit 3fdc365

File tree

9 files changed

+206
-38
lines changed

9 files changed

+206
-38
lines changed

.github/copilot-instructions.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Copilot Instructions for ggstatsplot
2+
3+
## Package Overview
4+
5+
`ggstatsplot` is an R package that creates `ggplot2`-based plots with statistical details included in the plots themselves. It serves as a visualization frontend for `statsExpressions`.
6+
7+
## Architecture
8+
9+
### Main Functions (R/)
10+
11+
- **Visualization functions**: `ggbetweenstats()`, `ggwithinstats()`, `gghistostats()`, `ggdotplotstats()`, `ggscatterstats()`, `ggcorrmat()`, `ggpiestats()`, `ggbarstats()`, `ggcoefstats()`
12+
- **Grouped variants**: `grouped_ggbetweenstats()`, etc. - repeat same analysis across grouping variable
13+
- **Each function supports 4 types** via `type` parameter: `"parametric"`, `"nonparametric"`, `"robust"`, `"bayes"`
14+
- **Output**: All functions return ggplot objects with statistical annotations
15+
16+
### Key Helper Functions
17+
18+
- `extract_stats()`: Extract statistical details from a ggstatsplot object
19+
- `extract_subtitle()`: Extract expression from subtitle
20+
- `extract_caption()`: Extract expression from caption
21+
- `theme_ggstatsplot()`: Default theme for plots
22+
- `combine_plots()`: Combine multiple plots using patchwork
23+
24+
### Dependencies
25+
26+
Core: `ggplot2`, `statsExpressions`, tidyverse stack (`dplyr`, `purrr`, `tidyr`, `rlang`), `patchwork`, `paletteer`, easystats ecosystem (`insight`, `parameters`, `performance`, `datawizard`, `correlation`)
27+
28+
## Developer Workflow
29+
30+
### Common Commands (via Makefile)
31+
32+
```bash
33+
make document # Generate documentation (roxygen2)
34+
make build # Build package tarball
35+
make check # Run R CMD check
36+
make install # Install package locally
37+
make lint # Run lintr checks
38+
make format # Format code with styler
39+
make install_deps # Install/update dependencies
40+
```
41+
42+
### Testing
43+
44+
- Framework: `testthat` (edition 3) with parallel execution
45+
- Run tests: `devtools::test()` or `make check`
46+
- **Snapshot tests**: Used for plot output verification via `vdiffr`
47+
- Test files mirror source files: `R/ggbetweenstats.R` -> `tests/testthat/test-ggbetweenstats.R`
48+
- Coverage requirement: **100%** (enforced by codecov)
49+
50+
### Adding New Tests
51+
52+
```r
53+
test_that("descriptive name", {
54+
set.seed(123)
55+
p <- function_under_test(data = dataset, x = var1, y = var2)
56+
expect_s3_class(p, "ggplot")
57+
vdiffr::expect_doppelganger("descriptive-name", p)
58+
})
59+
```
60+
61+
## Code Conventions
62+
63+
### Style
64+
65+
- **Linting**: Uses `lintr::all_linters()` with exceptions in `.lintr`
66+
- **Formatting**: `styler::style_pkg()` (run via `make format`)
67+
- **Naming**: snake_case for functions and variables
68+
- **Pipes**: Use base R `|>` pipe (NOT magrittr `%>%`)
69+
70+
### Roxygen Documentation
71+
72+
- Uses `roxygen2` with markdown support (`Roxygen: list(markdown = TRUE)`)
73+
- Uses `@autoglobal` annotation from `roxyglobals` for global variables
74+
- Template files in `man-roxygen/` for shared documentation
75+
- Run `make document` after modifying roxygen comments
76+
77+
### Function Parameters
78+
79+
Common parameters across functions:
80+
81+
- `data`: Input dataframe
82+
- `x`, `y`: Column names (unquoted, uses tidy evaluation)
83+
- `type`: One of `"parametric"`, `"nonparametric"`, `"robust"`, `"bayes"`
84+
- `paired`: Logical for paired/within-subjects designs
85+
- `results.subtitle`: Whether to show statistical results in subtitle
86+
- `centrality.plotting`: Whether to show centrality measure
87+
- `bf.message`: Whether to show Bayes factor message in caption
88+
- `ggtheme`: ggplot2 theme to use
89+
- `palette`, `package`: Color palette specifications
90+
91+
## Important Patterns
92+
93+
### Plot Construction
94+
95+
Functions build plots layer by layer using ggplot2:
96+
97+
```r
98+
ggplot(data, aes(x = x, y = y)) +
99+
geom_violin() +
100+
geom_boxplot() +
101+
labs(subtitle = stats_expression, caption = bf_expression) +
102+
theme_ggstatsplot()
103+
```
104+
105+
### Statistical Analysis Delegation
106+
107+
All statistical computations are delegated to `statsExpressions`:
108+
109+
```r
110+
statsExpressions::two_sample_test(data, x, y, type = type)
111+
```
112+
113+
### Grouped Functions
114+
115+
Use `purrr::pmap()` to apply function across groups:
116+
117+
```r
118+
purrr::pmap(list_of_args, ggbetweenstats) |>
119+
patchwork::wrap_plots()
120+
```
121+
122+
## Testing Tips
123+
124+
- Set seeds before tests: `set.seed(123)`
125+
- Use `skip_if_not_installed()` for optional dependencies
126+
- Use `vdiffr::expect_doppelganger()` for visual regression tests
127+
- Use `suppressWarnings()` when tests intentionally trigger warnings
128+
129+
## Files to Update Together
130+
131+
When modifying a function:
132+
133+
1. `R/<function>.R` - Source code
134+
2. `man/<function>.Rd` - Will auto-generate from roxygen
135+
3. `tests/testthat/test-<function>.R` - Tests
136+
4. `vignettes/web_only/<function>.Rmd` - Vignette (if exists)
137+
5. `NEWS.md` - Document user-facing changes
138+
139+
## CI/CD
140+
141+
- GitHub Actions workflows in `.github/workflows/`
142+
- Automated R CMD check on multiple platforms
143+
- Code coverage uploaded to Codecov (100% required)
144+
- Visual regression tests with vdiffr
145+
- Dependency updates via Dependabot

.github/workflows/check-no-warnings.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818

1919
- uses: r-lib/actions/setup-r@v2
2020
with:
21-
r-version: "devel"
2221
use-public-rspm: true
2322

2423
- uses: r-lib/actions/setup-r-dependencies@v2

.github/workflows/html-5-check.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919

2020
- uses: r-lib/actions/setup-r@v2
2121
with:
22-
r-version: "devel"
2322
use-public-rspm: true
2423

2524
- uses: r-lib/actions/setup-r-dependencies@v2

.github/workflows/pkgdown.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828

2929
- uses: r-lib/actions/setup-r@v2
3030
with:
31-
r-version: "devel"
3231
use-public-rspm: true
3332

3433
- uses: r-lib/actions/setup-r-dependencies@v2

.github/workflows/pre-commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v6
1616

17-
- uses: actions/setup-python@v6.1.0
17+
- uses: actions/setup-python@v6.2.0
1818
with:
1919
python-version: "3.13"
2020

.github/workflows/test-coverage.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,11 @@ jobs:
3131
- name: Test coverage
3232
run: |
3333
options(crayon.enabled = TRUE)
34-
covr::codecov(quiet = FALSE)
34+
cov <- covr::package_coverage()
35+
pct <- covr::percent_coverage(cov)
36+
cat(sprintf("\nCode coverage: %.2f%%\n", pct))
37+
covr::codecov(coverage = cov, quiet = FALSE)
38+
if (pct < 100) {
39+
stop(sprintf("Code coverage is %.2f%%, which is below the required 100%%", pct))
40+
}
3541
shell: Rscript {0}

DESCRIPTION

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ Depends:
2525
Imports:
2626
correlation (>= 0.8.8),
2727
datawizard (>= 1.3.0),
28-
dplyr (>= 1.1.4),
28+
dplyr (>= 1.2.0),
2929
ggcorrplot (>= 0.1.4.1),
30-
ggplot2 (>= 4.0.1),
30+
ggplot2 (>= 4.0.2),
3131
ggrepel (>= 0.9.6),
3232
ggside (>= 0.4.1),
3333
ggsignif (>= 0.6.4),
3434
glue (>= 1.8.0),
35-
insight (>= 1.4.3),
35+
insight (>= 1.4.6),
3636
magrittr (>= 2.0.4),
37-
paletteer (>= 1.6.0),
37+
paletteer (>= 1.7.0),
3838
parameters (>= 0.28.3),
3939
patchwork (>= 1.3.2),
40-
performance (>= 0.15.3),
41-
purrr (>= 1.2.0),
42-
rlang (>= 1.1.6),
43-
statsExpressions (>= 1.7.2),
44-
tidyr (>= 1.3.1),
40+
performance (>= 0.16.0),
41+
purrr (>= 1.2.1),
42+
rlang (>= 1.1.7),
43+
statsExpressions (>= 1.7.3),
44+
tidyr (>= 1.3.2),
4545
utils
4646
Suggests:
4747
afex,
@@ -59,13 +59,15 @@ Suggests:
5959
rstantools,
6060
stats,
6161
survival,
62-
testthat (>= 3.3.0),
62+
testthat (>= 3.3.2),
6363
tibble,
6464
vdiffr (>= 1.0.8),
6565
withr,
6666
WRS2
6767
VignetteBuilder:
6868
knitr
69+
Remotes:
70+
IndrajeetPatil/statsExpressions
6971
Config/Needs/check: anthonynorth/roxyglobals
7072
Config/roxyglobals/unique: TRUE
7173
Config/testthat/edition: 3

0 commit comments

Comments
 (0)