Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan for conflicts in internal functions? #108

Closed
emstruong opened this issue Feb 25, 2024 · 4 comments
Closed

Scan for conflicts in internal functions? #108

emstruong opened this issue Feb 25, 2024 · 4 comments

Comments

@emstruong
Copy link

emstruong commented Feb 25, 2024

Hello,

This is related to this

I'm not sure how to describe the issue, but is there a way to scan for conflicts in the internal functions of libraries?

Please see the following reprexes:

This works

library(conflicted)
library(psych)
library(psychTools)
data(iqitems, package = 'psychTools')
iq.keys <- c(4,4,4, 6,6,3,4,4,  5,2,2,4,  3,2,6,7)
conflicted::conflict_scout()
#> 0 conflicts
psych::score.multiple.choice(iq.keys,psychTools::iqitems)
#> Call: psych::score.multiple.choice(key = iq.keys, data = psychTools::iqitems)
#> 
#> (Unstandardized) Alpha:
#> [1] 0.84
#> 
#> Average item correlation:
#> [1] 0.25
#> 
#> item statistics 
#>           key    0    1    2    3    4    5    6    7    8 miss    r    n mean
#> reason.4    4 0.05 0.05 0.11 0.10 0.64 0.03 0.02 0.00 0.00    0 0.59 1523 0.64
#> reason.16   4 0.04 0.06 0.08 0.10 0.70 0.01 0.00 0.00 0.00    0 0.53 1524 0.70
#> reason.17   4 0.05 0.03 0.05 0.03 0.70 0.03 0.11 0.00 0.00    0 0.59 1523 0.70
#> reason.19   6 0.04 0.02 0.13 0.03 0.06 0.10 0.62 0.00 0.00    0 0.56 1523 0.62
#> letter.7    6 0.05 0.01 0.05 0.03 0.11 0.14 0.60 0.00 0.00    0 0.58 1524 0.60
#> letter.33   3 0.06 0.10 0.13 0.57 0.04 0.09 0.02 0.00 0.00    0 0.56 1523 0.57
#> letter.34   4 0.04 0.09 0.07 0.11 0.61 0.05 0.02 0.00 0.00    0 0.59 1523 0.61
#> letter.58   4 0.06 0.14 0.09 0.09 0.44 0.16 0.01 0.00 0.00    0 0.58 1525 0.44
#> matrix.45   5 0.04 0.01 0.06 0.14 0.18 0.53 0.04 0.00 0.00    0 0.51 1523 0.53
#> matrix.46   2 0.04 0.12 0.55 0.07 0.11 0.06 0.05 0.00 0.00    0 0.52 1524 0.55
#> matrix.47   2 0.04 0.05 0.61 0.07 0.11 0.06 0.06 0.00 0.00    0 0.55 1523 0.61
#> matrix.55   4 0.04 0.02 0.18 0.14 0.37 0.07 0.18 0.00 0.00    0 0.45 1524 0.37
#> rotate.3    3 0.04 0.03 0.04 0.19 0.22 0.15 0.05 0.12 0.15    0 0.51 1523 0.19
#> rotate.4    2 0.04 0.03 0.21 0.05 0.18 0.04 0.04 0.25 0.15    0 0.56 1523 0.21
#> rotate.6    6 0.04 0.22 0.02 0.05 0.14 0.05 0.30 0.04 0.14    0 0.55 1523 0.30
#> rotate.8    7 0.04 0.03 0.21 0.07 0.16 0.05 0.13 0.19 0.13    0 0.48 1524 0.19
#>             sd
#> reason.4  0.48
#> reason.16 0.46
#> reason.17 0.46
#> reason.19 0.49
#> letter.7  0.49
#> letter.33 0.50
#> letter.34 0.49
#> letter.58 0.50
#> matrix.45 0.50
#> matrix.46 0.50
#> matrix.47 0.49
#> matrix.55 0.48
#> rotate.3  0.40
#> rotate.4  0.41
#> rotate.6  0.46
#> rotate.8  0.39

Created on 2024-02-25 with reprex v2.1.0

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.2 (2023-10-31)
#>  os       Ubuntu 22.04.4 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_CA:en
#>  collate  en_CA.UTF-8
#>  ctype    en_CA.UTF-8
#>  tz       CENSORED
#>  date     2024-02-25
#>  pandoc   3.1.1 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version date (UTC) lib source
#>  P cachem        1.0.8   2023-05-01 [?] CRAN (R 4.3.0)
#>    cli           3.6.2   2023-12-11 [1] RSPM (R 4.3.0)
#>  P conflicted  * 1.2.0   2023-02-01 [?] CRAN (R 4.3.0)
#>  P digest        0.6.33  2023-07-07 [?] CRAN (R 4.3.1)
#>  P evaluate      0.23    2023-11-01 [?] RSPM (R 4.3.0)
#>  P fastmap       1.1.1   2023-02-24 [?] CRAN (R 4.3.0)
#>  P foreign       0.8-85  2023-09-09 [3] CRAN (R 4.3.2)
#>  P fs            1.6.2   2023-04-25 [?] CRAN (R 4.3.0)
#>    glue          1.7.0   2024-01-09 [1] RSPM (R 4.3.0)
#>  P htmltools     0.5.7   2023-11-03 [?] RSPM (R 4.3.0)
#>  P knitr         1.45    2023-10-30 [?] RSPM (R 4.3.0)
#>  P lattice       0.21-9  2023-10-01 [?] CRAN (R 4.3.2)
#>    lifecycle     1.0.4   2023-11-07 [1] RSPM (R 4.3.0)
#>  P magrittr      2.0.3   2022-03-30 [?] CRAN (R 4.3.0)
#>  P memoise       2.0.1   2021-11-26 [?] CRAN (R 4.3.0)
#>  P mnormt        2.1.1   2022-09-26 [?] CRAN (R 4.3.0)
#>  P nlme          3.1-162 2023-01-31 [?] CRAN (R 4.3.0)
#>  P psych       * 2.4.1   2024-01-18 [?] RSPM (R 4.3.2)
#>  P psychTools  * 2.4.2   2024-01-18 [?] RSPM (R 4.3.0)
#>  P purrr         1.0.1   2023-01-10 [?] CRAN (R 4.3.0)
#>  P R.cache       0.16.0  2022-07-21 [?] CRAN (R 4.3.0)
#>  P R.methodsS3   1.8.2   2022-06-13 [?] CRAN (R 4.3.0)
#>  P R.oo          1.26.0  2024-01-24 [?] RSPM (R 4.3.0)
#>  P R.utils       2.12.3  2023-11-18 [?] RSPM (R 4.3.0)
#>  P reprex        2.1.0   2024-01-11 [?] RSPM (R 4.3.0)
#>    rlang         1.1.3   2024-01-10 [1] RSPM (R 4.3.0)
#>  P rmarkdown     2.25    2023-09-18 [?] RSPM (R 4.3.0)
#>  P rstudioapi    0.15.0  2023-07-07 [?] CRAN (R 4.3.1)
#>  P sessioninfo   1.2.2   2021-12-06 [?] CRAN (R 4.3.0)
#>  P styler        1.10.2  2023-08-29 [?] RSPM (R 4.3.0)
#>    vctrs         0.6.5   2023-12-01 [1] RSPM (R 4.3.0)
#>    withr         3.0.0   2024-01-16 [1] RSPM (R 4.3.0)
#>  P xfun          0.42    2024-02-08 [?] RSPM (R 4.3.0)
#>  P yaml          2.3.8   2023-12-11 [?] RSPM (R 4.3.0)
#> 
#>  [1] /home/CENSORED/renv/library/R-4.3/x86_64-pc-linux-gnu
#>  [2] /home/CENSORED/R/renv/sandbox/R-4.3/x86_64-pc-linux-gnu/0b2508b5
#>  [3] /home/CENSORED/.asdf/installs/r/4.3.2/lib/R/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

But this doesn't

library(conflicted)
library(qgraph)
library(psych)
library(psychTools)
data(iqitems, package = 'psychTools')
iq.keys <- c(4,4,4, 6,6,3,4,4,  5,2,2,4,  3,2,6,7)
conflicted::conflict_scout()
#> 0 conflicts
psych::score.multiple.choice(iq.keys,psychTools::iqitems)
#> Warning in cbind(key, response.freq, item.cor, item.stats): number of rows of
#> result is not a multiple of vector length (arg 4)
#> Error in round(item.stats, digits): non-numeric argument to mathematical function

Created on 2024-02-25 with reprex v2.1.0

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.2 (2023-10-31)
#>  os       Ubuntu 22.04.4 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_CA:en
#>  collate  en_CA.UTF-8
#>  ctype    en_CA.UTF-8
#>  tz       CENSORED
#>  date     2024-02-25
#>  pandoc   3.1.1 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version date (UTC) lib source
#>  P abind         1.4-5   2016-07-21 [?] CRAN (R 4.3.0)
#>  P backports     1.4.1   2021-12-13 [?] CRAN (R 4.3.0)
#>  P base64enc     0.1-3   2015-07-28 [?] CRAN (R 4.3.0)
#>  P cachem        1.0.8   2023-05-01 [?] CRAN (R 4.3.0)
#>  P checkmate     2.3.1   2023-12-04 [?] RSPM (R 4.3.0)
#>    cli           3.6.2   2023-12-11 [1] RSPM (R 4.3.0)
#>  P cluster       2.1.4   2022-08-22 [3] CRAN (R 4.3.2)
#>  P colorspace    2.1-0   2023-01-23 [?] CRAN (R 4.3.0)
#>  P conflicted  * 1.2.0   2023-02-01 [?] CRAN (R 4.3.0)
#>  P corpcor       1.6.10  2021-09-16 [?] CRAN (R 4.3.0)
#>    data.table    1.15.0  2024-01-30 [1] RSPM (R 4.3.0)
#>  P digest        0.6.33  2023-07-07 [?] CRAN (R 4.3.1)
#>  P dplyr         1.1.2   2023-04-20 [?] CRAN (R 4.3.0)
#>  P evaluate      0.23    2023-11-01 [?] RSPM (R 4.3.0)
#>    fansi         1.0.6   2023-12-08 [1] RSPM (R 4.3.0)
#>  P fastmap       1.1.1   2023-02-24 [?] CRAN (R 4.3.0)
#>  P fdrtool       1.2.17  2021-11-13 [?] CRAN (R 4.3.0)
#>  P foreign       0.8-85  2023-09-09 [3] CRAN (R 4.3.2)
#>  P Formula       1.2-5   2023-02-24 [?] CRAN (R 4.3.0)
#>  P fs            1.6.2   2023-04-25 [?] CRAN (R 4.3.0)
#>  P generics      0.1.3   2022-07-05 [?] CRAN (R 4.3.0)
#>    ggplot2       3.4.4   2023-10-12 [1] RSPM (R 4.3.0)
#>  P glasso        1.11    2019-10-01 [?] CRAN (R 4.3.0)
#>    glue          1.7.0   2024-01-09 [1] RSPM (R 4.3.0)
#>  P gridExtra     2.3     2017-09-09 [?] CRAN (R 4.3.0)
#>    gtable        0.3.4   2023-08-21 [1] RSPM (R 4.3.0)
#>  P gtools        3.9.5   2023-11-20 [?] CRAN (R 4.3.1)
#>  P Hmisc         5.1-1   2023-09-12 [?] CRAN (R 4.3.1)
#>  P htmlTable     2.4.2   2023-10-29 [?] RSPM (R 4.3.0)
#>  P htmltools     0.5.7   2023-11-03 [?] RSPM (R 4.3.0)
#>  P htmlwidgets   1.6.4   2023-12-06 [?] RSPM (R 4.3.0)
#>  P igraph        2.0.2   2024-02-17 [?] RSPM (R 4.3.0)
#>  P jpeg          0.1-10  2022-11-29 [?] CRAN (R 4.3.0)
#>  P knitr         1.45    2023-10-30 [?] RSPM (R 4.3.0)
#>  P lattice       0.21-9  2023-10-01 [?] CRAN (R 4.3.2)
#>  P lavaan        0.6-17  2023-12-20 [?] RSPM (R 4.3.0)
#>    lifecycle     1.0.4   2023-11-07 [1] RSPM (R 4.3.0)
#>  P magrittr      2.0.3   2022-03-30 [?] CRAN (R 4.3.0)
#>  P Matrix        1.6-5   2024-01-11 [?] CRAN (R 4.3.2)
#>  P memoise       2.0.1   2021-11-26 [?] CRAN (R 4.3.0)
#>  P mnormt        2.1.1   2022-09-26 [?] CRAN (R 4.3.0)
#>  P munsell       0.5.0   2018-06-12 [?] CRAN (R 4.3.0)
#>  P nlme          3.1-162 2023-01-31 [?] CRAN (R 4.3.0)
#>  P nnet          7.3-19  2023-05-03 [?] CRAN (R 4.3.0)
#>  P pbapply       1.7-2   2023-06-27 [?] CRAN (R 4.3.1)
#>  P pbivnorm      0.6.0   2015-01-23 [?] CRAN (R 4.3.0)
#>  P pillar        1.9.0   2023-03-22 [?] CRAN (R 4.3.0)
#>  P pkgconfig     2.0.3   2019-09-22 [?] CRAN (R 4.3.0)
#>  P plyr          1.8.9   2023-10-02 [?] CRAN (R 4.3.1)
#>  P png           0.1-8   2022-11-29 [?] CRAN (R 4.3.0)
#>  P psych       * 2.4.1   2024-01-18 [?] RSPM (R 4.3.2)
#>  P psychTools  * 2.4.2   2024-01-18 [?] RSPM (R 4.3.0)
#>  P purrr         1.0.1   2023-01-10 [?] CRAN (R 4.3.0)
#>  P qgraph      * 1.9.8   2023-11-03 [?] CRAN (R 4.3.1)
#>  P quadprog      1.5-8   2019-11-20 [?] CRAN (R 4.3.0)
#>  P R.cache       0.16.0  2022-07-21 [?] CRAN (R 4.3.0)
#>  P R.methodsS3   1.8.2   2022-06-13 [?] CRAN (R 4.3.0)
#>  P R.oo          1.26.0  2024-01-24 [?] RSPM (R 4.3.0)
#>  P R.utils       2.12.3  2023-11-18 [?] RSPM (R 4.3.0)
#>  P R6            2.5.1   2021-08-19 [?] CRAN (R 4.3.0)
#>  P Rcpp          1.0.10  2023-01-22 [?] CRAN (R 4.3.0)
#>  P reprex        2.1.0   2024-01-11 [?] RSPM (R 4.3.0)
#>  P reshape2      1.4.4   2020-04-09 [?] CRAN (R 4.3.0)
#>    rlang         1.1.3   2024-01-10 [1] RSPM (R 4.3.0)
#>  P rmarkdown     2.25    2023-09-18 [?] RSPM (R 4.3.0)
#>  P rpart         4.1.21  2023-10-09 [3] CRAN (R 4.3.2)
#>  P rstudioapi    0.15.0  2023-07-07 [?] CRAN (R 4.3.1)
#>    scales        1.3.0   2023-11-28 [1] RSPM (R 4.3.0)
#>  P sessioninfo   1.2.2   2021-12-06 [?] CRAN (R 4.3.0)
#>  P stringi       1.7.12  2023-01-11 [?] CRAN (R 4.3.0)
#>  P stringr       1.5.1   2023-11-14 [?] CRAN (R 4.3.1)
#>  P styler        1.10.2  2023-08-29 [?] RSPM (R 4.3.0)
#>  P tibble        3.2.1   2023-03-20 [?] CRAN (R 4.3.0)
#>  P tidyselect    1.2.0   2022-10-10 [?] CRAN (R 4.3.0)
#>    utf8          1.2.4   2023-10-22 [1] RSPM (R 4.3.0)
#>    vctrs         0.6.5   2023-12-01 [1] RSPM (R 4.3.0)
#>    withr         3.0.0   2024-01-16 [1] RSPM (R 4.3.0)
#>  P xfun          0.42    2024-02-08 [?] RSPM (R 4.3.0)
#>  P yaml          2.3.8   2023-12-11 [?] RSPM (R 4.3.0)
#> 
#>  [1] /home/CENSORED/renv/library/R-4.3/x86_64-pc-linux-gnu
#>  [2] /home/CENSORED/R/renv/sandbox/R-4.3/x86_64-pc-linux-gnu/0b2508b5
#>  [3] /home/CENSORED/installs/r/4.3.2/lib/R/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

I don't know the right terminology to use, but I thought conflicts in the internal functions were supposed to be impossible or else you'd have no idea whether the combination of packages you've loaded may have led to computational irreproducibility. It also makes testing for correctness of results very difficult...

@hadley
Copy link
Member

hadley commented Feb 26, 2024

Yeah, this indicates a problem with the psych package. It's unfortunately outside of the scope of conflicted.

@hadley hadley closed this as completed Feb 26, 2024
@emstruong
Copy link
Author

emstruong commented Feb 26, 2024

Yeah, this indicates a problem with the psych package. It's unfortunately outside of the scope of conflicted.

Might there be a way for automatically checking/knowing what went wrong? Somehow I had the impression that this class of bugs was supposed to be impossible--it makes me worry if there might be other combinations of packages that are affecting each other in ways that not even conflicted can tell...

@hadley
Copy link
Member

hadley commented Feb 26, 2024

@emstruong it is generally impossible. The fact that psych is experiencing suggests that it's using some sort of custom evaluation mechanism or something is wrong with its namespace. It's a not a widespread problem that you need to worry about.

@emstruong
Copy link
Author

Alright, well I'm convinced by that--thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants