Skip to content

Commit

Permalink
Merge branch 'main' into propagations-september-2024
Browse files Browse the repository at this point in the history
  • Loading branch information
walkowif authored Sep 13, 2024
2 parents f66626c + 148787b commit ed9f8e9
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 86 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ pkgdown
^\.covrignore$
^cran-comments\.md$
^CRAN-SUBMISSION$

# reverse dep cehcks
^checked$
19 changes: 19 additions & 0 deletions .github/workflows/recheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
workflow_dispatch:
inputs:
which:
type: choice
description: Which dependents to check
options:
- strong
- most

name: Reverse dependency check

jobs:
revdep_check:
name: Reverse check ${{ inputs.which }} dependents
uses: r-devel/recheck/.github/workflows/recheck.yml@v1
with:
which: ${{ inputs.which }}
subdirectory: '' #if your package is in a git subdir
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ docs
.DS_Store
temp/


.pre-commit-config.yaml
tests/testthat/_snaps/**/*.new.md
tests/testthat/_snaps/**/*.new.svg

# reverse dep cehcks
checked/
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 0.2.0
Date: 2024-07-20 17:12:32 UTC
SHA: 214cf55600df7d6a5037acbb88c135afba284c91
Version: 0.2.1
Date: 2024-09-03 01:03:13 UTC
SHA: 1c9a44df460938bfc90d1833fd6410a0387935da
11 changes: 5 additions & 6 deletions 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.2.0.9011
Version: 0.2.1.9001
Authors@R: c(
person("Daniel", "Sjoberg", , "[email protected]", role = c("aut", "cre")),
person("Abinaya", "Yogasekaram", , "[email protected]", role = "aut"),
Expand All @@ -19,32 +19,31 @@ BugReports: https://github.com/insightsengineering/cardx/issues
Depends:
R (>= 4.1)
Imports:
cards (>= 0.2.1.9006),
cards (>= 0.2.2),
cli (>= 3.6.1),
dplyr (>= 1.1.2),
glue (>= 1.6.2),
lifecycle (>= 1.0.3),
rlang (>= 1.1.1),
tidyr (>= 1.3.0)
Suggests:
aod (>= 1.3.3),
broom (>= 1.0.5),
broom.helpers (>= 1.15.0),
broom.helpers (>= 1.17.0),
broom.mixed (>= 0.2.9),
car (>= 3.1-2),
effectsize (>= 0.8.8),
emmeans (>= 1.7.3),
geepack (>= 1.3.2),
ggsurvfit (>= 1.1.0),
lme4 (>= 1.1-35.1),
lme4 (>= 1.1-35.5),
parameters (>= 0.20.2),
smd (>= 0.6.6),
spelling (>= 2.3.0),
survey (>= 4.2),
survival (>= 3.6-4),
testthat (>= 3.2.0),
withr (>= 2.5.0)
Remotes:
insightsengineering/cards
Config/Needs/website: insightsengineering/nesttemplate
Config/testthat/edition: 3
Config/testthat/parallel: true
Expand Down
14 changes: 12 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# cardx 0.2.0.9011
# cardx 0.2.1.9001

* Bug fix in `ard_categorical.survey.design()` where all unweighted statistics were returned, even in the case where they were explicitly not requested.
# cardx 0.2.1

## New Features and Updates

* Added S3 method `ard_total_n.survey.design()` which returns an ARD with both the survey-weighted and unweighted total sample size.

* Added `warning` and `error` columns to `ard_regression()` output. (#148)

* Implemented `cards::as_card()` where needed in the package to convert data frames to class 'card'. (#200)

## Bug Fixes

* Bug fix in `ard_categorical.survey.design()` where all unweighted statistics were returned, even in the case where they were explicitly not requested.

## Lifecycle Changes

* The `bt(pattern)`, `reformulate2(pattern_term)`, `reformulate2(pattern_response)` arguments have been deprecated and are now ignored. We now use `make.names()` to determine whether a column name needs to be wrapped in backticks. (#192)

# cardx 0.2.0

### Breaking Changes
Expand Down
29 changes: 15 additions & 14 deletions R/construction_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
#' @param package (`string`)\cr
#' string of package name that will be temporarily loaded when function
#' specified in `method` is executed.
#' @param pattern (`string`)\cr
#' regular expression string. If the regex matches, backticks are added
#' to the string. When `NULL`, backticks are not added.
#' @param pattern_term,pattern_response passed to `bt(pattern)` for arguments
#' `stats::reformulate(termlabels, response)`.
#' @param pattern,pattern_term,pattern_response DEPRECATED
#' @inheritParams rlang::eval_tidy
#' @inheritParams stats::reformulate
#' @inheritParams rlang::args_dots_empty
Expand Down Expand Up @@ -172,27 +168,32 @@ construct_model.survey.design <- function(data, formula, method, method.args = l
#' @rdname construction_helpers
#' @export
reformulate2 <- function(termlabels, response = NULL, intercept = TRUE,
pattern_term = "[ \n\r]", pattern_response = "[ \n\r]",
env = parent.frame()) {
env = parent.frame(),
pattern_term = NULL, pattern_response = NULL) {
# deprecated argument --------------------------------------------------------
if (!missing(pattern_term)) lifecycle::deprecate_warn("0.2.1", what = "cardx::reformulate2(pattern_term)", details = "Argument has been ignored.") # styler: off
if (!missing(pattern_response)) lifecycle::deprecate_warn("0.2.1", what = "cardx::reformulate2(pattern_response)", details = "Argument has been ignored.") # styler: off

stats::reformulate(
termlabels = bt(termlabels, pattern_term),
response = bt(response, pattern_response),
termlabels = bt(termlabels),
response = bt(response),
intercept = intercept,
env = env
)
}

#' @rdname construction_helpers
#' @export
bt <- function(x, pattern = "[ \n\r]") {
bt <- function(x, pattern = NULL) {
# deprecated argument --------------------------------------------------------
if (!missing(pattern)) lifecycle::deprecate_warn("0.2.1", what = "cardx::bt(pattern)", details = "Argument has been ignored.") # styler: off

if (is_empty(x)) {
return(x)
}
if (is_empty(pattern)) {
return(x)
}

ifelse(
str_detect(x, pattern = pattern) & !str_detect(x, "^`.*`$"),
make.names(x) != x & !str_detect(x, "^`.*`$"),
paste0("`", x, "`"),
x
)
Expand Down
7 changes: 7 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

0 errors ✔ | 0 warnings ✔ | 0 notes ✔

## revdepcheck results

We checked 4 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages

## Additional Comments

* Thank you for your time!
15 changes: 5 additions & 10 deletions man/construction_helpers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions revdep/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Platform

|field |value |
|:--------|:---------------------------------------------------------------------------------------------------|
|version |R version 4.3.3 (2024-02-29) |
|os |macOS Ventura 13.4.1 |
|system |aarch64, darwin20 |
|ui |RStudio |
|language |(EN) |
|collate |en_US.UTF-8 |
|ctype |en_US.UTF-8 |
|tz |America/Los_Angeles |
|date |2024-09-02 |
|rstudio |2024.04.2+764.pro1 Chocolate Cosmos (desktop) |
|pandoc |3.1.11 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown) |

# Dependencies

|package |old |new |Δ |
|:-------|:-----|:----------|:--|
|cardx |0.2.0 |0.2.0.9015 |* |
|cards |0.2.2 |0.2.2 | |
|cli |NA |3.6.3 |* |
|cpp11 |NA |0.4.7 |* |
|withr |NA |3.0.1 |* |

# Revdeps

7 changes: 7 additions & 0 deletions revdep/cran.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## revdepcheck results

We checked 4 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages

1 change: 1 addition & 0 deletions revdep/failures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*Wow, no problems at all. :)*
1 change: 1 addition & 0 deletions revdep/problems.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*Wow, no problems at all. :)*
17 changes: 0 additions & 17 deletions tests/testthat/_snaps/ard_stats_chisq_test.md

This file was deleted.

17 changes: 8 additions & 9 deletions tests/testthat/_snaps/construction_helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

Code
dplyr::filter(as.data.frame(ard_regression(construct_model(data = dplyr::rename(
mtcars, `M P G` = mpg), formula = reformulate2(c("M P G", "cyl"), response = "hp"),
method = "lm"))), stat_name %in% c("term", "estimate", "p.value"))
mtcars, `M P G` = mpg, `c/yl` = cyl), formula = reformulate2(c("M P G",
"c/yl"), response = "hp"), method = "lm"))), stat_name %in% c("term",
"estimate"))
Output
variable context stat_name stat_label stat fmt_fn warning error
1 M P G regression term term `M P G` NULL NULL NULL
2 M P G regression estimate Coefficient -2.774769 1 NULL NULL
3 M P G regression p.value p-value 0.2125285 1 NULL NULL
4 cyl regression term term cyl NULL NULL NULL
5 cyl regression estimate Coefficient 23.97863 1 NULL NULL
6 cyl regression p.value p-value 0.002814958 1 NULL NULL
variable context stat_name stat_label stat fmt_fn warning error
1 M P G regression term term `M P G` NULL NULL NULL
2 M P G regression estimate Coefficient -2.774769 1 NULL NULL
3 c/yl regression term term `c/yl` NULL NULL NULL
4 c/yl regression estimate Coefficient 23.97863 1 NULL NULL

# construct_model() messaging

Expand Down
20 changes: 0 additions & 20 deletions tests/testthat/test-ard_stats_chisq_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,6 @@ test_that("ard_stats_chisq_test() works", {
)
})

test_that("shuffle_ard fills missing group levels if the group is meaningful", {
adsl_sub <- cards::ADSL |> dplyr::filter(ARM %in% unique(ARM)[1:2])

expect_snapshot(
cards::bind_ard(
ard_stats_chisq_test(
data = adsl_sub,
by = "ARM",
variables = "AGEGR1"
),
ard_stats_chisq_test(
data = adsl_sub,
by = "SEX",
variables = "AGEGR1"
)
) |>
cards::shuffle_ard() |>
as.data.frame()
)
})

test_that("ard_stats_chisq_test() follows ard structure", {
expect_silent(
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-construction_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ skip_if_not(is_pkg_installed(c("broom.helpers", "withr", "survey", "survival"),
test_that("construct_model() works", {
expect_snapshot(
construct_model(
data = mtcars |> dplyr::rename(`M P G` = mpg),
formula = reformulate2(c("M P G", "cyl"), response = "hp"),
data = mtcars |> dplyr::rename(`M P G` = mpg, `c/yl` = cyl),
formula = reformulate2(c("M P G", "c/yl"), response = "hp"),
method = "lm"
) |>
ard_regression() |>
as.data.frame() |>
dplyr::filter(stat_name %in% c("term", "estimate", "p.value"))
dplyr::filter(stat_name %in% c("term", "estimate"))
)

expect_equal(
Expand All @@ -26,7 +26,7 @@ test_that("construct_model() works", {
)

expect_equal(
cardx::bt("`a b`"),
bt("`a b`"),
"`a b`"
)

Expand Down

0 comments on commit ed9f8e9

Please sign in to comment.