pivot_wider.() assigns names to variables in incorrect order, when:
names_glue parameter is used with {.value} placeholder
variable is names_from is unsorted
Error is reproducible in both current CRAN version and development version.
See minimal example below. With names_glue (df2) columns are ordered as they would be without this option (df1), but column names are ordered as values appear in the lettr column. This issue is solved, when letter variable is sorted beforehand (df3).
pivot_wider.()
assigns names to variables in incorrect order, when:names_glue
parameter is used with{.value}
placeholdernames_from
is unsortedError is reproducible in both current CRAN version and development version. See minimal example below. With
names_glue
(df2) columns are ordered as they would be without this option (df1), but column names are ordered as values appear in the lettr column. This issue is solved, when letter variable is sorted beforehand (df3).Created on 2022-09-05 with reprex v2.0.2
Session info
``` r > sessioninfo::session_info() ─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.2.1 (2022-06-23 ucrt) os Windows 10 x64 (build 22000) system x86_64, mingw32 ui RStudio language (EN) collate Russian_Russia.utf8 ctype Russian_Russia.utf8 tz Europe/Moscow date 2022-09-05 rstudio 2022.07.0+548 Spotted Wakerobin (desktop) pandoc 2.18 @ C:/Program Files/RStudio/bin/quarto/bin/tools/ (via rmarkdown) ─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── package * version date (UTC) lib source callr 3.7.2 2022-08-22 [1] CRAN (R 4.2.1) cli 3.3.0 2022-04-25 [1] CRAN (R 4.2.0) clipr 0.8.0 2022-02-22 [1] CRAN (R 4.2.0) crayon 1.5.1 2022-03-26 [1] CRAN (R 4.2.0) curl 4.3.2 2021-06-23 [1] CRAN (R 4.2.0) data.table 1.14.2 2021-09-27 [1] CRAN (R 4.2.0) digest 0.6.29 2021-12-01 [1] CRAN (R 4.2.0) ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.0) evaluate 0.16 2022-08-09 [1] CRAN (R 4.2.1) fansi 1.0.3 2022-03-24 [1] CRAN (R 4.2.0) fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.0) fs 1.5.2 2021-12-08 [1] CRAN (R 4.2.0) glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0) highr 0.9 2021-04-16 [1] CRAN (R 4.2.0) htmltools 0.5.3 2022-07-18 [1] CRAN (R 4.2.1) knitr 1.40 2022-08-24 [1] CRAN (R 4.2.1) lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.2.0) magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0) pillar 1.8.1 2022-08-19 [1] CRAN (R 4.2.1) pkgbuild 1.3.1 2021-12-20 [1] CRAN (R 4.2.0) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.0) prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.2.0) processx 3.7.0 2022-07-07 [1] CRAN (R 4.2.1) ps 1.7.1 2022-06-18 [1] CRAN (R 4.2.0) purrr 0.3.4 2020-04-17 [1] CRAN (R 4.2.0) R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0) remotes 2.4.2 2021-11-30 [1] CRAN (R 4.2.0) reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.1) rlang 1.0.5 2022-08-31 [1] CRAN (R 4.2.1) rmarkdown 2.16 2022-08-24 [1] CRAN (R 4.2.1) rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.2.0) rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.1) sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0) tibble 3.1.8 2022-07-22 [1] CRAN (R 4.2.1) tidyselect 1.1.2 2022-02-21 [1] CRAN (R 4.2.0) tidytable 0.8.1.9 2022-09-05 [1] Github (markfairbanks/tidytable@5267e8a) utf8 1.2.2 2021-07-24 [1] CRAN (R 4.2.0) vctrs 0.4.1 2022-04-13 [1] CRAN (R 4.2.0) withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.0) xfun 0.32 2022-08-10 [1] CRAN (R 4.2.1) yaml 2.3.5 2022-02-21 [1] CRAN (R 4.2.0) [1] C:/Users/Darx/AppData/Local/R/win-library/4.2 [2] C:/Program Files/R/R-4.2.1/library ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ```