metrumresearchgroup / pmtables

TeX tables for pharmacometrics.
https://metrumresearchgroup.github.io/pmt-book
11 stars 1 forks source link

Incompatibility with tidyr 1.2.0 #256

Closed kyleam closed 2 years ago

kyleam commented 2 years ago

The test suite fails with 1.2.0:

failures ``` > devtools::test() ℹ Loading pmtables ℹ Testing pmtables ✔ | F W S OK | Context ✔ | 4 | test-align ✔ | 10 | test-as_stable [0.8s] ✔ | 9 | test-check ✔ | 5 | test-clear_reps ✔ | 15 | test-cont-data [0.2s] ✔ | 44 | test-cont-table [1.3s] ✖ | 1 49 | test-demo-check [3.8s] ───────────────────────────────────────────────────────────────────────────────────────────────────────────── Error (test-demo-check.R:451:1): (code run outside of `test_that()`) Error in `stop_subscript(class = "vctrs_error_subscript_oob", i = i, subscript_type = subscript_type, ...)`: Can't subset columns that don't exist. ✖ Column `FORMf` doesn't exist. Backtrace: 1. pmtables::pt_cat_long(...) at test-demo-check.R:451:0 2. pmtables::cat_data(data = data, cols = cols, by = span, nby = nspan) at pmtables/R/discrete_table.R:156:2 4. tidyr:::pivot_wider.data.frame(...) at tidyr/R/pivot-wide.R:171:2 5. tidyr::pivot_wider_spec(...) at tidyr/R/pivot-wide.R:213:2 6. tidyr:::select_wider_id_cols(...) at tidyr/R/pivot-wide.R:292:2 ... at tidyselect/R/eval-walk.R:150:2 23. tidyselect:::chr_as_locations(x, vars) at tidyselect/R/eval-walk.R:171:2 24. vctrs::vec_as_location(x, n = length(vars), names = vars) at tidyselect/R/eval-walk.R:180:2 25. vctrs ``() at vctrs/R/subscript-loc.R:64:2 26. vctrs:::stop_subscript_oob(...) 27. vctrs:::stop_subscript(...) at vctrs/R/subscript-loc.R:418:2 ───────────────────────────────────────────────────────────────────────────────────────────────────────────── ✖ | 3 31 | test-demographics-table [6.5s] ───────────────────────────────────────────────────────────────────────────────────────────────────────────── Error (test-demographics-table.R:137:3): demographics data summary - units Error in `stop_subscript(class = "vctrs_error_subscript_oob", i = i, subscript_type = subscript_type, ...)`: Can't subset columns that don't exist. ✖ Column `STUDYf` doesn't exist. Backtrace: 1. pmtables::pt_demographics(...) at test-demographics-table.R:137:2 2. pmtables::pt_cat_long(...) at pmtables/R/demographics-table.R:241:4 3. pmtables::cat_data(data = data, cols = cols, by = span, nby = nspan) at pmtables/R/discrete_table.R:156:2 5. tidyr:::pivot_wider.data.frame(...) at tidyr/R/pivot-wide.R:171:2 6. tidyr::pivot_wider_spec(...) at tidyr/R/pivot-wide.R:213:2 ... at tidyselect/R/eval-walk.R:150:2 24. tidyselect:::chr_as_locations(x, vars) at tidyselect/R/eval-walk.R:171:2 25. vctrs::vec_as_location(x, n = length(vars), names = vars) at tidyselect/R/eval-walk.R:180:2 26. vctrs ``() at vctrs/R/subscript-loc.R:64:2 27. vctrs:::stop_subscript_oob(...) 28. vctrs:::stop_subscript(...) at vctrs/R/subscript-loc.R:418:2 Error (test-demographics-table.R:149:3): demographics data summary - column renaming (no units) Error in `stop_subscript(class = "vctrs_error_subscript_oob", i = i, subscript_type = subscript_type, ...)`: Can't subset columns that don't exist. ✖ Column `STUDYf` doesn't exist. Backtrace: 1. pmtables::pt_demographics(...) at test-demographics-table.R:149:2 2. pmtables::pt_cat_long(...) at pmtables/R/demographics-table.R:241:4 3. pmtables::cat_data(data = data, cols = cols, by = span, nby = nspan) at pmtables/R/discrete_table.R:156:2 5. tidyr:::pivot_wider.data.frame(...) at tidyr/R/pivot-wide.R:171:2 6. tidyr::pivot_wider_spec(...) at tidyr/R/pivot-wide.R:213:2 ... at tidyselect/R/eval-walk.R:150:2 24. tidyselect:::chr_as_locations(x, vars) at tidyselect/R/eval-walk.R:171:2 25. vctrs::vec_as_location(x, n = length(vars), names = vars) at tidyselect/R/eval-walk.R:180:2 26. vctrs ``() at vctrs/R/subscript-loc.R:64:2 27. vctrs:::stop_subscript_oob(...) 28. vctrs:::stop_subscript(...) at vctrs/R/subscript-loc.R:418:2 Error (test-demographics-table.R:163:3): demographics data summary - column renaming (with units) Error in `stop_subscript(class = "vctrs_error_subscript_oob", i = i, subscript_type = subscript_type, ...)`: Can't subset columns that don't exist. ✖ Column `STUDYf` doesn't exist. Backtrace: 1. pmtables::pt_demographics(...) at test-demographics-table.R:163:2 2. pmtables::pt_cat_long(...) at pmtables/R/demographics-table.R:241:4 3. pmtables::cat_data(data = data, cols = cols, by = span, nby = nspan) at pmtables/R/discrete_table.R:156:2 5. tidyr:::pivot_wider.data.frame(...) at tidyr/R/pivot-wide.R:171:2 6. tidyr::pivot_wider_spec(...) at tidyr/R/pivot-wide.R:213:2 ... at tidyselect/R/eval-walk.R:150:2 24. tidyselect:::chr_as_locations(x, vars) at tidyselect/R/eval-walk.R:171:2 25. vctrs::vec_as_location(x, n = length(vars), names = vars) at tidyselect/R/eval-walk.R:180:2 26. vctrs ``() at vctrs/R/subscript-loc.R:64:2 27. vctrs:::stop_subscript_oob(...) 28. vctrs:::stop_subscript(...) at vctrs/R/subscript-loc.R:418:2 ───────────────────────────────────────────────────────────────────────────────────────────────────────────── ✔ | 24 | test-digits ✔ | 18 | test-cat-data [1.1s] ✔ | 38 | test-discrete-table [5.0s] ✔ | 29 | test-expected [3.2s] ✔ | 9 | test-hline ✔ | 13 | test-inventory-data [0.6s] ✔ | 51 | test-inventory-table [1.2s] ✔ | 21 | test-longtable [0.4s] ✔ | 25 | test-new_names ✔ | 21 | test-notes ✖ | 1 15 | test-panel [0.2s] ───────────────────────────────────────────────────────────────────────────────────────────────────────────── Error (test-panel.R:18:3): panel duplicates Error in `stop_vctrs(message, class = c(class, "vctrs_error_incompatible"), x = x, y = y, details = details, ...)`: Can't convert `replace` to match type of `data` . Backtrace: 1. pmtables inspect(data, panel = as.panel("A", duplicates_ok = TRUE)) at test-panel.R:18:2 4. pmtables::stable.data.frame(..., inspect = TRUE) at pmtables/R/table-stable.R:111:10 5. pmtables::tab_panel(data, panel, sumrows) at pmtables/R/table-stable.R:172:2 7. tidyr:::replace_na.default(data[[paneln]], "") at tidyr/R/replace_na.R:31:2 8. vctrs::vec_assign(data, missing, replace, x_arg = "data", value_arg = "replace") at tidyr/R/replace_na.R:45:2 ... at vctrs/R/slice.R:181:2 10. vctrs::vec_default_cast(...) 11. vctrs::stop_incompatible_cast(...) at vctrs/R/cast.R:156:2 12. vctrs::stop_incompatible_type(...) at vctrs/R/conditions.R:131:2 13. vctrs:::stop_incompatible(...) at vctrs/R/conditions.R:110:2 14. vctrs:::stop_vctrs(...) at vctrs/R/conditions.R:69:2 ───────────────────────────────────────────────────────────────────────────────────────────────────────────── ✔ | 6 | test-pmtable [0.2s] ✔ | 17 | test-preview.R [0.4s] ✔ | 16 | test-sanitize [0.1s] ✔ | 2 | test-sizes ✔ | 22 | test-span [0.5s] ✔ | 14 | test-summary-functions.R ✔ | 2 | test-sumrow ✔ | 37 | test-tab_cols [0.3s] ✖ | 1 32 | test-table-object.R [0.6s] ───────────────────────────────────────────────────────────────────────────────────────────────────────────── Error (test-table-object.R:55:3): stobject equivalent panel Error in `stop_vctrs(message, class = c(class, "vctrs_error_incompatible"), x = x, y = y, details = details, ...)`: Can't convert `replace` to match type of `data` . Backtrace: 1. pmtables inspect(mt, panel = "cyl") at test-table-object.R:55:2 4. pmtables::stable.data.frame(..., inspect = TRUE) at pmtables/R/table-stable.R:111:10 5. pmtables::tab_panel(data, panel, sumrows) at pmtables/R/table-stable.R:172:2 7. tidyr:::replace_na.default(data[[paneln]], "") at tidyr/R/replace_na.R:31:2 8. vctrs::vec_assign(data, missing, replace, x_arg = "data", value_arg = "replace") at tidyr/R/replace_na.R:45:2 ... at vctrs/R/slice.R:181:2 10. vctrs::vec_default_cast(...) 11. vctrs::stop_incompatible_cast(...) at vctrs/R/cast.R:156:2 12. vctrs::stop_incompatible_type(...) at vctrs/R/conditions.R:131:2 13. vctrs:::stop_incompatible(...) at vctrs/R/conditions.R:110:2 14. vctrs:::stop_vctrs(...) at vctrs/R/conditions.R:69:2 ───────────────────────────────────────────────────────────────────────────────────────────────────────────── ✔ | 19 | test-utils-table.R ✔ | 26 | test-utils ✔ | 6 | test-yaml_as_df ══ Results ══════════════════════════════════════════════════════════════════════════════════════════════════ Duration: 27.5 s [ FAIL 6 | WARN 0 | SKIP 0 | PASS 630 ] ```

These failures begin with tidyr's c3b3c6e (Update replace_na() to utilize vctrs, 2021-11-18).

https://github.com/tidyverse/tidyr/commit/c3b3c6e83bca2b12dc1a08e6aecfd2d67f94bb2c

kyleam commented 2 years ago

Fixed by gh-257.