Skip to content

Commit

Permalink
Merge branch 'main' into 126-ard_survfit_diff
Browse files Browse the repository at this point in the history
  • Loading branch information
ddsjoberg authored Apr 29, 2024
2 parents 94b77a8 + 1e2a461 commit bdbdf2b
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ pkgdown
# others
^renv$
^renv\.lock$
^.revdeprefs\.yaml$
^revdep$
^\.covrignore$
23 changes: 23 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 🔤
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/cla.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .github/workflows/on-demand.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 2 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ temp/


.pre-commit-config.yaml
tests/testthat/_snaps/**/*.new.md
tests/testthat/_snaps/**/*.new.svg
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre")),
person("Abinaya", "Yogasekaram", , "[email protected]", role = "aut"),
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cardx 0.1.0.9028
# cardx 0.1.0.9031

### Breaking Changes

Expand Down
6 changes: 3 additions & 3 deletions R/ard_survey_svycontinuous.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion R/ard_survey_svyranktest.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
)
Expand Down
2 changes: 1 addition & 1 deletion R/ard_survey_svyttest.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions revdep/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
checks
library
checks.noindex
library.noindex
cloud.noindex
data.sqlite
*.html
16 changes: 15 additions & 1 deletion tests/testthat/test-ard_regression.R
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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()))
})

0 comments on commit bdbdf2b

Please sign in to comment.