Pivots
Verification
Scope
Output columns, rows, and warnings of pivotLongerSpec() and pivotWiderSpec(): NA dropping, multi-part names, value types, and duplicate keys.
References
- Reference
- tidyr 1.3.2 pivot_longer_spec() and pivot_wider_spec(), on R 4.6.1
- Versions
- R 4.6.1, dplyr 1.2.1, tidyr 1.3.2, jsonlite 2.0.0, PHP 8.5.10, php_polars 0.1.0
Data
- pivot cases
- Inputs, specs, and tidyr output Source
Method
tests/r/pivot.R writes each input, spec, and tidyr result. The PHP tests apply the same specs on a DataFrame and a PolarsTable. Fixtures regenerated with the listed R versions on 2026-11-01; output byte-identical to the committed files.
- Check
- Comparison with a reference implementation
- Recorded
- 2026-11-02, PHP 8.5.10, macOS 27.0.1 (arm64), commit 1abdeb1
Tolerances
exact equality
Applies to: Columns, rows in order, and warnings
Numbers as doubles, a length-1 list cell as its value
x: package value; r: reference value.
Results
20 comparisons in 10 cases: 20 pass, 0 fail, 0 skipped.
By case
| Case | Comparisons | Status |
|---|---|---|
| longer_simple | 2 | pass |
| longer_drop_na | 2 | pass |
| longer_value | 2 | pass |
| longer_value_drop_na | 2 | pass |
| longer_combine | 2 | pass |
| wider_simple | 2 | pass |
| wider_fill | 2 | pass |
| wider_multi | 2 | pass |
| wider_id_cols | 2 | pass |
| wider_dupes | 2 | pass |
Every comparison
| Case | Implementation | Quantity | Values | Status |
|---|---|---|---|---|
| longer_simple | DataFrame | pivot longer | 18 | pass |
| longer_drop_na | DataFrame | pivot longer | 15 | pass |
| longer_value | DataFrame | pivot longer | 24 | pass |
| longer_value_drop_na | DataFrame | pivot longer | 20 | pass |
| longer_combine | DataFrame | pivot longer | 12 | pass |
| wider_simple | DataFrame | pivot wider | 12 | pass |
| wider_fill | DataFrame | pivot wider | 12 | pass |
| wider_multi | DataFrame | pivot wider | 12 | pass |
| wider_id_cols | DataFrame | pivot wider | 10 | pass |
| wider_dupes | DataFrame | pivot wider | 6 | pass |
| longer_simple | Polars | pivot longer | 18 | pass |
| longer_drop_na | Polars | pivot longer | 15 | pass |
| longer_value | Polars | pivot longer | 24 | pass |
| longer_value_drop_na | Polars | pivot longer | 20 | pass |
| longer_combine | Polars | pivot longer | 12 | pass |
| wider_simple | Polars | pivot wider | 12 | pass |
| wider_fill | Polars | pivot wider | 12 | pass |
| wider_multi | Polars | pivot wider | 12 | pass |
| wider_id_cols | Polars | pivot wider | 10 | pass |
| wider_dupes | Polars | pivot wider | 6 | pass |
Reproduction
Rscript tests/r/pivot.R
php vendor/bin/pest tests/PivotTest.php
php -d extension=php_polars.so php vendor/bin/pest tests/Polars/PolarsPivotTest.php
- Raw record
- site/verifications/pivot-tidyr.json
- Input data
- tests/fixtures/pivot/cases.json