diff --git a/.Rbuildignore b/.Rbuildignore index 821ac9f2e..259162938 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -35,3 +35,6 @@ pkgdown # others ^renv$ ^renv\.lock$ +^.revdeprefs\.yaml$ +^revdep$ +^\.covrignore$ diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index c35021adf..0d554b6e1 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -35,6 +35,27 @@ jobs: checking Rd .usage sections .* NOTE checking for unstated dependencies in vignettes .* NOTE checking top-level files .* NOTE + r-cmd-non-cran: + name: R CMD Check (non-CRAN) đŸ§Ŧ + uses: insightsengineering/r.pkg.template/.github/workflows/build-check-install.yaml@main + secrets: + REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} + with: + enforce-note-blocklist: true + publish-unit-test-report-gh-pages: false + junit-xml-comparison: false + concurrency-group: non-cran + disable-unit-test-reports: true + skip-r-cmd-install: true + note-blocklist: | + checking dependencies in R code .* NOTE + checking R code for possible problems .* NOTE + checking examples .* NOTE + checking Rd line widths .* NOTE + checking S3 generic/method consistency .* NOTE + checking Rd .usage sections .* NOTE + checking for unstated dependencies in vignettes .* NOTE + checking top-level files .* NOTE coverage: name: Coverage 📔 uses: insightsengineering/r.pkg.template/.github/workflows/test-coverage.yaml@main @@ -77,6 +98,8 @@ jobs: uses: insightsengineering/r.pkg.template/.github/workflows/style.yaml@main with: auto-update: false + secrets: + REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} grammar: if: github.event_name != 'push' name: Grammar Check 🔤 diff --git a/.github/workflows/cla.yaml b/.github/workflows/cla.yaml new file mode 100644 index 000000000..b674b0b45 --- /dev/null +++ b/.github/workflows/cla.yaml @@ -0,0 +1,18 @@ +name: CLA 🔏 + +on: + issue_comment: + types: + - created + # For PRs that originate from forks + pull_request_target: + types: + - opened + - closed + - synchronize + +jobs: + CLA: + name: CLA 📝 + uses: insightsengineering/.github/.github/workflows/cla.yaml@main + secrets: inherit diff --git a/.github/workflows/on-demand.yaml b/.github/workflows/on-demand.yaml new file mode 100644 index 000000000..02843bb32 --- /dev/null +++ b/.github/workflows/on-demand.yaml @@ -0,0 +1,12 @@ +--- +name: On-demand 🧑‍đŸ”Ŧ + +on: + schedule: + - cron: '45 3 * * 0' + workflow_dispatch: + +jobs: + revdepcheck: + name: revdepcheck ↩ī¸ + uses: insightsengineering/r.pkg.template/.github/workflows/revdepcheck.yaml@main diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e1bf66405..4e2487b83 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,15 +8,6 @@ on: workflow_dispatch: jobs: - build: - name: Build package 🎁 - needs: release - uses: insightsengineering/r.pkg.template/.github/workflows/build-check-install.yaml@main - secrets: - REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} - with: - skip-r-cmd-check: true - skip-r-cmd-install: true docs: name: Pkgdown Docs 📚 needs: release @@ -36,8 +27,8 @@ jobs: uses: insightsengineering/r.pkg.template/.github/workflows/release.yaml@main secrets: REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} - r-cmd: - name: R CMD Check đŸ§Ŧ + build: + name: Build package and reports 🎁 needs: [release, docs] uses: insightsengineering/r.pkg.template/.github/workflows/build-check-install.yaml@main secrets: diff --git a/.gitignore b/.gitignore index 25330c565..0c09a97e9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ temp/ .pre-commit-config.yaml +tests/testthat/_snaps/**/*.new.md +tests/testthat/_snaps/**/*.new.svg diff --git a/DESCRIPTION b/DESCRIPTION index 3839a677f..ad29a2478 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9028 +Version: 0.1.0.9031 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), @@ -28,6 +28,7 @@ Suggests: aod (>= 1.3.3), broom (>= 1.0.5), broom.helpers (>= 1.15.0), + broom.mixed (>= 0.2.9), car (>= 3.0-11), effectsize (>= 0.6.0), emmeans (>= 1.7.3), diff --git a/NEWS.md b/NEWS.md index 27ee17f65..7773a2543 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9028 +# cardx 0.1.0.9031 ### Breaking Changes diff --git a/R/ard_survey_svycontinuous.R b/R/ard_survey_svycontinuous.R index d9c40afa4..16d51fd5d 100644 --- a/R/ard_survey_svycontinuous.R +++ b/R/ard_survey_svycontinuous.R @@ -213,7 +213,7 @@ accepted_svy_stats <- function(expand_quantiles = TRUE) { # if no by variable, calculate univariate statistics if (is_empty(by)) { - args$x <- stats::reformulate(variable) + args$x <- reformulate2(variable) # calculate statistic (and remove FUN from the argument list) stat <- cards::eval_capture_conditions( @@ -244,8 +244,8 @@ accepted_svy_stats <- function(expand_quantiles = TRUE) { # if there is by variable(s), calculate statistics for the combinations else { - args$formula <- stats::reformulate(variable) - args$by <- stats::reformulate(by) + args$formula <- reformulate2(variable) + args$by <- reformulate2(by) stat <- if (stat_name %in% c("median", paste0("p", 0:100))) { cards::eval_capture_conditions( diff --git a/R/ard_survey_svyranktest.R b/R/ard_survey_svyranktest.R index 38fe77c5e..33b015a60 100644 --- a/R/ard_survey_svyranktest.R +++ b/R/ard_survey_svyranktest.R @@ -48,7 +48,7 @@ ard_survey_svyranktest <- function(data, by, variables, test, ...) { variable = variable, lst_tidy = cards::eval_capture_conditions( - survey::svyranktest(stats::reformulate(by, response = variable), design = data, test = test, ...) |> + survey::svyranktest(reformulate2(termlabels = by, response = variable), design = data, test = test, ...) |> broom::tidy() ) ) diff --git a/R/ard_survey_svyttest.R b/R/ard_survey_svyttest.R index 2e6ea91d6..ac4ee7825 100644 --- a/R/ard_survey_svyttest.R +++ b/R/ard_survey_svyttest.R @@ -46,7 +46,7 @@ ard_survey_svyttest <- function(data, by, variables, conf.level = 0.95, ...) { variable = variable, lst_tidy = cards::eval_capture_conditions( - survey::svyttest(stats::reformulate(by, response = variable), design = data, ...) %>% + survey::svyttest(reformulate2(termlabels = by, response = variable), design = data, ...) %>% # a slightly enhanced tidier that allows us to specify the conf.level { dplyr::bind_cols( diff --git a/revdep/.gitignore b/revdep/.gitignore new file mode 100644 index 000000000..111ab324f --- /dev/null +++ b/revdep/.gitignore @@ -0,0 +1,7 @@ +checks +library +checks.noindex +library.noindex +cloud.noindex +data.sqlite +*.html diff --git a/tests/testthat/test-ard_regression.R b/tests/testthat/test-ard_regression.R index 7b834e764..91610c3d2 100644 --- a/tests/testthat/test-ard_regression.R +++ b/tests/testthat/test-ard_regression.R @@ -1,4 +1,4 @@ -skip_if_not(do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom.helpers", reference_pkg = "cardx"))) +skip_if_not(is_pkg_installed(pkg = "broom.helpers", reference_pkg = "cardx")) test_that("ard_regression() works", { expect_snapshot( @@ -21,6 +21,20 @@ test_that("ard_regression() works", { ) }) +test_that("ard_regression() works specifying custom tidier", { + skip_if_not(is_pkg_installed(pkg = c("lme4", "broom.mixed"), reference_pkg = "cardx")) + expect_snapshot( + lme4::lmer(mpg ~ hp + (1 | cyl), data = mtcars) |> + ard_regression(tidy_fun = broom.mixed::tidy) |> + as.data.frame() |> + dplyr::select(-context, -stat_label, -fmt_fn) |> + dplyr::filter(map_lgl(stat, is.numeric)) |> + dplyr::mutate( + stat = lapply(stat, function(x) ifelse(is.numeric(x), cards::round5(x, 3), x)) + ) + ) +}) + test_that("ard_regression() does not produce `variable_level` column where not applicable", { expect_true(!"variable_level" %in% names(lm(mpg ~ hp, mtcars) |> ard_regression())) })