You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a user were to pass a function to ard_continuous() that returns a tibble or named list, then what we get back is far less informative. We should have some capability of also passing what is expected to be returned, so in the case of an error, we can returned an ARD of the correct structure.
library(cards)
# great when there are no errors
ard_continuous(
ADSL,
variables=AGE,
statistic= everything() ~list(ttest= \(x) t.test(x) |>broom::tidy())
)
#> {cards} data frame: 8 x 8#> variable context stat_name stat_label stat fmt_fn#> 1 AGE continuo… estimate estimate 75.087 1#> 2 AGE continuo… statistic statistic 145.119 1#> 3 AGE continuo… p.value p.value 0 1#> 4 AGE continuo… parameter parameter 253 1#> 5 AGE continuo… conf.low conf.low 74.068 1#> 6 AGE continuo… conf.high conf.high 76.106 1#> 7 AGE continuo… method method One Samp… <fn>#> 8 AGE continuo… alternative alternat… two.sided <fn>#> ℹ 2 more variables: warning, error# but when there is an error, it's unclear
ard_continuous(
ADSL,
variables=AGEGR1,
statistic= everything() ~list(ttest= \(x) t.test(x) |>broom::tidy())
) |>
as.data.frame()
#> variable context stat_name stat_label stat fmt_fn#> 1 AGEGR1 continuous ttest ttest NULL .Primitive("as.character")#> warning#> 1 argument is not numeric or logical: returning NA, NAs introduced by coercion#> error#> 1 missing value where TRUE/FALSE needed
The first thing that comes to mind is assigning an attribute to the function itself of the expected statistics to be returned. Then if there is an error, we can inspect the function itself for the expected statistics. It's not great....but the only idea I have for now
The text was updated successfully, but these errors were encountered:
IDEA: Export a function that makes it easy to add an attribute with the expected return. The function takes in a function and a vector of stat_names. In the case of an error, the expected stat_names would be sued to construct an empty ARD (with the error column populated).
The function could also specify other items like the the fmt_fn.
Related to insightsengineering/cardx#203
If a user were to pass a function to
ard_continuous()
that returns a tibble or named list, then what we get back is far less informative. We should have some capability of also passing what is expected to be returned, so in the case of an error, we can returned an ARD of the correct structure.Created on 2024-09-08 with reprex v2.1.0
The first thing that comes to mind is assigning an attribute to the function itself of the expected statistics to be returned. Then if there is an error, we can inspect the function itself for the expected statistics. It's not great....but the only idea I have for now
The text was updated successfully, but these errors were encountered: