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

assert_package() didn't return min version #1296

Closed
ddsjoberg opened this issue Jul 19, 2022 · 8 comments · Fixed by larmarange/broom.helpers#171
Closed

assert_package() didn't return min version #1296

ddsjoberg opened this issue Jul 19, 2022 · 8 comments · Fixed by larmarange/broom.helpers#171
Milestone

Comments

@ddsjoberg
Copy link
Owner

print(gtsummary:::assert_package("emmeans"))
#> NULL

Created on 2022-07-19 by the reprex package (v2.0.1)

@larmarange
Copy link
Collaborator

Similarly, broom.helpers::.get_min_version_required() doesn't work in GitHub actions (see examples in https://larmarange.github.io/broom.helpers/reference/assert_package.html ) while it's working properly locally on my PC.

@ddsjoberg
Copy link
Owner Author

I think it'll work better to use installed.packages() which stores the min version numbers (as opposed parsing the DESCRIPTION file).

@larmarange
Copy link
Collaborator

I'm not sure to see your point. You will still have to parse the DESCRIPTION of the package returned by installed.packages() to know the minimum version required by a specific package.

@ddsjoberg
Copy link
Owner Author

The returned object from installed.packages() includes the information in Imports, Suggests, etc.

df_pkg_details <-
  installed.packages() |> 
  tibble::as_tibble() |> 
  dplyr::filter(Package == "gtsummary") |> 
  dplyr::select(Depends, Imports, LinkingTo, Suggests, Enhances)
df_pkg_details$Suggests
#> [1] "aod (>= 1.3.1), broom.mixed (>= 0.2.7), car (>= 3.0-11),\ncmprsk, covr, effectsize (>= 0.6.0), emmeans (>= 1.7.3),\nflextable (>= 0.6.10), geepack, GGally (>= 2.1.0), Hmisc,\nhuxtable (>= 5.4.0), insight (>= 0.15.0), kableExtra (>=\n1.3.4), lme4, mgcv, mice (>= 3.10.0), nnet, officer, openxlsx,\nparameters (>= 0.18.1), parsnip (>= 0.1.7), rmarkdown, sandwich\n(>= 3.0.1), scales, smd (>= 0.6.6), spelling (>= 2.2), survey,\nsurvival (>= 3.2-11), testthat (>= 3.0.4), tidycmprsk (>=\n0.1.2), workflows (>= 0.2.4)"

Created on 2022-07-19 by the reprex package (v2.0.1)

@larmarange
Copy link
Collaborator

Would something like that be useful in broom.helpers ?

library(tidyverse)

.get_dependencies <- function(pkg = "broom.helpers") {
  utils::installed.packages() %>%
    tibble::as_tibble() %>%
    dplyr::filter(.data$Package == .env$pkg) %>%
    dplyr::select(dplyr::all_of(c("Imports", "Depends", "Suggests", "Enhances", "LinkingTo"))) %>%
    tidyr::pivot_longer(dplyr::everything(), values_to = "package", names_to = "dependency_type") %>%
    tidyr::separate_rows(.data$package, sep = ",") %>%
    dplyr::mutate(package = stringr::str_squish(.data$package)) %>%
    tidyr::separate(.data$package, into = c("package", "version"), sep = " ", extra = "merge", fill = "right") %>%
    dplyr::filter(!is.na(.data$package))
}

.get_dependencies() %>% knitr::kable()
dependency_type package version
Imports broom NA
Imports cli NA
Imports dplyr NA
Imports labelled NA
Imports lifecycle NA
Imports purrr NA
Imports rlang (>= 1.0.1)
Imports stats NA
Imports stringr NA
Imports tibble NA
Imports tidyr NA
Depends R (>= 3.4)
Suggests biglm NA
Suggests biglmm NA
Suggests brms (>= 2.13.0)
Suggests broom.mixed NA
Suggests cmprsk NA
Suggests covr NA
Suggests datasets NA
Suggests emmeans NA
Suggests fixest (>= 0.10.0)
Suggests forcats NA
Suggests gam NA
Suggests gee NA
Suggests geepack NA
Suggests ggplot2 NA
Suggests glmmTMB NA
Suggests glue NA
Suggests gt NA
Suggests gtsummary NA
Suggests knitr NA
Suggests lavaan NA
Suggests lfe NA
Suggests lme4 (>= 1.1.28)
Suggests MASS NA
Suggests mgcv NA
Suggests mice NA
Suggests nnet NA
Suggests ordinal NA
Suggests parameters NA
Suggests parsnip NA
Suggests plm NA
Suggests rmarkdown NA
Suggests rstanarm NA
Suggests spelling NA
Suggests survey NA
Suggests survival NA
Suggests testthat NA
Suggests tidycmprsk NA
Suggests VGAM NA
.get_dependencies("gtsummary") %>% knitr::kable()
dependency_type package version
Imports broom (>= 0.8.0)
Imports broom.helpers (>= 1.7.0.9003)
Imports cli (>= 3.1.1)
Imports dplyr (>= 1.0.7)
Imports forcats (>= 0.5.1)
Imports glue (>= 1.6.0)
Imports gt (>= 0.6.0)
Imports knitr (>= 1.37)
Imports lifecycle (>= 1.0.1)
Imports purrr (>= 0.3.4)
Imports rlang (>= 0.4.12)
Imports stringr (>= 1.4.0)
Imports tibble (>= 3.1.6)
Imports tidyr (>= 1.1.4)
Depends R (>= 3.4)
Suggests aod (>= 1.3.1)
Suggests broom.mixed (>= 0.2.7)
Suggests car (>= 3.0-11)
Suggests cmprsk NA
Suggests covr NA
Suggests effectsize (>= 0.6.0)
Suggests emmeans (>= 1.7.3)
Suggests flextable (>= 0.6.10)
Suggests geepack NA
Suggests GGally (>= 2.1.0)
Suggests Hmisc NA
Suggests huxtable (>= 5.4.0)
Suggests insight (>= 0.15.0)
Suggests kableExtra (>= 1.3.4)
Suggests lme4 NA
Suggests mgcv NA
Suggests mice (>= 3.10.0)
Suggests nnet NA
Suggests officer NA
Suggests openxlsx NA
Suggests parameters (>= 0.18.1)
Suggests parsnip (>= 0.1.7)
Suggests rmarkdown NA
Suggests sandwich (>= 3.0.1)
Suggests scales NA
Suggests smd (>= 0.6.6)
Suggests spelling (>= 2.2)
Suggests survey NA
Suggests survival (>= 3.2-11)
Suggests testthat (>= 3.0.4)
Suggests tidycmprsk (>= 0.1.2)
Suggests workflows (>= 0.2.4)

Created on 2022-07-19 by the reprex package (v2.0.1)

@ddsjoberg ddsjoberg reopened this Jul 19, 2022
@ddsjoberg
Copy link
Owner Author

I think this a great function to include, and we can update .get_min_version_required() to pull the information from here, rather than parsing DESCRIPTION.

@ddsjoberg

This comment was marked as outdated.

larmarange added a commit to larmarange/broom.helpers that referenced this issue Jul 19, 2022
new function `.get_package_dependencies()`

`.assert_package()` now checks the type of comparison for minimum version

cf. ddsjoberg/gtsummary#1296
@larmarange
Copy link
Collaborator

larmarange commented Jul 19, 2022

You may have a look at larmarange/broom.helpers#171

New function .get_package_dependencies() returning a tibble with all dependencies, minimum version and comparison operator.

.get_min_version_required() now returns the comparison operator as an attribute

The comparison operator is taken into account by .asset_package()

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

Successfully merging a pull request may close this issue.

2 participants