Skip to content

Commit

Permalink
feat: #10 add fmt_fn
Browse files Browse the repository at this point in the history
  • Loading branch information
zdz2101 committed Mar 6, 2024
1 parent 769bd48 commit 3cdd708
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
10 changes: 10 additions & 0 deletions R/ard_vif.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ ard_vif <- function(x, ...) {
.data$stat_name == "aGVIF",
"Adjusted GVIF",
.data$stat_name
),
fmt_fn = map(
.data$stat,
function(.x) {
# styler: off
if (is.integer(.x)) return(0L)
if (is.numeric(.x)) return(1L)
# styler: on
NULL
}
)
)

Expand Down
20 changes: 10 additions & 10 deletions tests/testthat/_snaps/ard_vif.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Code
ard_vif(lm(AGE ~ ARM + SEX, data = cards::ADSL))
Message
{cards} data frame: 6 x 7
{cards} data frame: 6 x 8
Output
variable context stat_name stat_label stat
1 ARM vif GVIF GVIF 1.016
2 ARM vif df df 2
3 ARM vif aGVIF Adjusted… 1.004
4 SEX vif GVIF GVIF 1.016
5 SEX vif df df 1
6 SEX vif aGVIF Adjusted… 1.008
variable context stat_name stat_label stat fmt_fn
1 ARM vif GVIF GVIF 1.016 1
2 ARM vif df df 2 1
3 ARM vif aGVIF Adjusted… 1.004 1
4 SEX vif GVIF GVIF 1.016 1
5 SEX vif df df 1 1
6 SEX vif aGVIF Adjusted… 1.008 1
Message
i 2 more variables: warning, error

Expand All @@ -20,11 +20,11 @@
Code
ard_vif(lm(AGE ~ ARM, data = cards::ADSL))
Message
{cards} data frame: 2 x 7
{cards} data frame: 2 x 8
Output
variable context stat_name stat_label stat error
1 ARMXanomeline High Dose vif VIF VIF model co…
2 ARMXanomeline Low Dose vif VIF VIF model co…
Message
i 1 more variable: warning
i 2 more variables: fmt_fn, warning

0 comments on commit 3cdd708

Please sign in to comment.