From 3764851b544224c0e3d7f5ee9da4aeecf83f222a Mon Sep 17 00:00:00 2001 From: Zelos Zhu Date: Sat, 27 Apr 2024 17:40:45 -0400 Subject: [PATCH 1/6] Closes #104 address use of `reformulate()` for nonsyntactic names (#138) **What changes are proposed in this pull request?** Address use of `reformulate()` for nonsyntactic names by adopting `reformulate2()` from model construction helpers **Reference GitHub issue associated with pull request.** Closes #104 -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [ ] If a bug was fixed, a unit test was added. - [ ] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [ ] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [ ] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom", reference_pkg = "cardx")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom"", reference_pkg = "cardx"))` - [ ] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [ ] If a bug was fixed, a unit test was added. - [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --- R/ard_survey_svycontinuous.R | 6 +++--- R/ard_survey_svyranktest.R | 2 +- R/ard_survey_svyttest.R | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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( From d829023c93921d1735311cfe9cf93bd1933de2a4 Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Sat, 27 Apr 2024 21:41:32 +0000 Subject: [PATCH 2/6] [skip actions] Bump version to 0.1.0.9029 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3839a677f..67a8c2966 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.9029 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 27ee17f65..f601b69db 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9028 +# cardx 0.1.0.9029 ### Breaking Changes From 0c71e4e46974c32da19969435e69ab2ebbc4a81d Mon Sep 17 00:00:00 2001 From: walkowif <59475134+walkowif@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:23:48 +0200 Subject: [PATCH 3/6] Workflow propagation (#76) Propagation of: * https://github.com/insightsengineering/idr-tasks/issues/355 * https://github.com/insightsengineering/idr-tasks/issues/756 * https://github.com/insightsengineering/idr-tasks/issues/757 * https://github.com/insightsengineering/idr-tasks/issues/712 * https://github.com/insightsengineering/idr-tasks/issues/764 --------- Signed-off-by: cicdguy <26552821+cicdguy@users.noreply.github.com> Co-authored-by: cicdguy <26552821+cicdguy@users.noreply.github.com> --- .Rbuildignore | 3 +++ .github/workflows/check.yaml | 23 +++++++++++++++++++++++ .github/workflows/cla.yaml | 18 ++++++++++++++++++ .github/workflows/on-demand.yaml | 12 ++++++++++++ .github/workflows/release.yaml | 13 ++----------- .gitignore | 2 ++ revdep/.gitignore | 7 +++++++ 7 files changed, 67 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/cla.yaml create mode 100644 .github/workflows/on-demand.yaml create mode 100644 revdep/.gitignore 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/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 From eb5ed4633e3ed5f9e2a69483e998abb8756fa103 Mon Sep 17 00:00:00 2001 From: cicdguy Date: Mon, 29 Apr 2024 15:24:43 +0000 Subject: [PATCH 4/6] [skip actions] Bump version to 0.1.0.9030 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 67a8c2966..382a2817f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9029 +Version: 0.1.0.9030 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index f601b69db..e6bd80f3e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9029 +# cardx 0.1.0.9030 ### Breaking Changes From 7c0bb41d7cb5733cfea0d727e450b87f56da2027 Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Mon, 29 Apr 2024 13:03:46 -0700 Subject: [PATCH 5/6] adding broom.mixed test --- DESCRIPTION | 1 + tests/testthat/test-ard_regression.R | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3839a677f..7940a3542 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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/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())) }) From 1e2a461ca5f8dc883296dd0a02d0ae805371a2bb Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Mon, 29 Apr 2024 20:04:52 +0000 Subject: [PATCH 6/6] [skip actions] Bump version to 0.1.0.9031 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 77cc2174d..ad29a2478 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9030 +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"), diff --git a/NEWS.md b/NEWS.md index e6bd80f3e..7773a2543 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9030 +# cardx 0.1.0.9031 ### Breaking Changes