berndbischl / BBmisc

Other
20 stars 7 forks source link

`sortByCol()` fails in BBmisc 1.12 #92

Open pat-s opened 2 years ago

pat-s commented 2 years ago

This caused an error in one of the {mlr} tests. cc @mllg

library(data.table)
library(BBmisc)
#> 
#> Attaching package: 'BBmisc'
#> The following object is masked from 'package:base':
#> 
#>     isFALSE

DT <- data.table(
  A = sample(3, 10, TRUE),
  B = sample(letters[1:3], 10, TRUE)
)

sortByCol(DT, "A")
#> Error in `[.data.table`(x, , col, drop = FALSE): j (the 2nd argument inside [...]) is a single symbol but column name 'col' is not found. Perhaps you intended DT[, ..col]. This difference to data.frame is deliberate and explained in FAQ 1.1.

Created on 2022-03-14 by the reprex package (v2.0.1)

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.1.3 (2022-03-10) #> os macOS Monterey 12.2.1 #> system aarch64, darwin20 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Zurich #> date 2022-03-14 #> pandoc 2.17.1.1 @ /Applications/RStudio.app/Contents/Resources/app/bin/quarto/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> backports 1.4.1 2021-12-13 [1] CRAN (R 4.1.1) #> BBmisc * 1.12 2022-03-10 [1] CRAN (R 4.1.3) #> checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.1.2) #> cli 3.2.0 2022-02-14 [1] CRAN (R 4.1.1) #> crayon 1.5.0 2022-02-14 [1] CRAN (R 4.1.2) #> data.table * 1.14.2 2021-09-27 [1] CRAN (R 4.1.2) #> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.2) #> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.2) #> evaluate 0.15 2022-02-18 [1] CRAN (R 4.1.2) #> fansi 1.0.2 2022-01-14 [1] CRAN (R 4.1.2) #> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.2) #> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.1) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.1.2) #> highr 0.9 2021-04-16 [1] CRAN (R 4.1.2) #> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.2) #> knitr 1.37 2021-12-16 [1] CRAN (R 4.1.1) #> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.2) #> magrittr 2.0.2 2022-01-26 [1] CRAN (R 4.1.2) #> pillar 1.7.0 2022-02-01 [1] CRAN (R 4.1.2) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.2) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.2) #> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.2) #> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.1.2) #> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.1.2) #> R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.2) #> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.2) #> rlang 1.0.2.9000 2022-03-05 [1] Github (r-lib/rlang@6ef0256) #> rmarkdown 2.13 2022-03-10 [1] CRAN (R 4.1.3) #> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.2) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.2) #> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.2) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.2) #> styler 1.6.2 2021-09-23 [1] CRAN (R 4.1.1) #> tibble 3.1.6 2021-11-07 [1] CRAN (R 4.1.2) #> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.2) #> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.2) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.1.2) #> xfun 0.30 2022-03-02 [1] CRAN (R 4.1.2) #> yaml 2.3.5 2022-02-21 [1] CRAN (R 4.1.2) #> #> [1] /Users/pjs/Library/R/arm64/4.1/library #> [2] /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library #> #> ────────────────────────────────────────────────────────────────────────────── ```

AFAICS

https://github.com/berndbischl/BBmisc/blob/8f9c97c76123c2a187da2c57e012cd39a23e7cfb/R/sortByCol.R#L24

should be

 args = as.list(x[, ..col, drop = FALSE])