-
Notifications
You must be signed in to change notification settings - Fork 53
1089 always avail alt df #1102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
1089 always avail alt df #1102
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1044,7 +1044,11 @@ NULL | |
| #' \item{.all_col_exprs}{List of expressions. Each of them represents a different column splitting.} | ||
| #' \item{.all_col_counts}{Vector of integers. Each of them represents the global count for each column. It differs | ||
| #' if `alt_counts_df` is used (see [build_table()]).} | ||
| #' } | ||
| #' | ||
| #' For the `.alt_df*` family of parameters, these will be passed data | ||
| #' subsets based on `df` if no `alt_counts_df` is specified in the | ||
| #' `build_table` call. In `rtables` versions `<= 0.6.13`, this instead | ||
| #' resulted in an error. } | ||
| #' | ||
| #' @note If any of these formals is specified incorrectly or not present in the tabulation machinery, it will be | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to the note just below (line 1056): it still says |
||
| #' treated as if missing. For example, `.ref_group` will be missing if no baseline is previously defined during | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,9 +166,6 @@ test_that(".spl_context and afun extra parameters contain information about comb | |
|
|
||
| # NB: If you add keep_levels = c("all_X") to add_combo_levels the other | ||
| # column expressions are missing -> Expected! | ||
| expect_error(lyt |> build_table(DM), | ||
| regexp = "Layout contains afun\\/cfun functions that have optional*" | ||
| ) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor leftover: removing the old |
||
| tbl <- lyt |> build_table(DM, alt_counts_df = ex_adsl) | ||
|
|
||
|
|
@@ -352,10 +349,6 @@ test_that(".alt_df_row appears in cfun but not in afun.", { | |
| split_rows_by("ARMCD") |> | ||
| analyze("BMRKR1", afun = afun_tmp) | ||
|
|
||
| expect_error( | ||
| lyt |> build_table(ex_adsl), | ||
| "Layout contains afun/cfun functions that have optional*" | ||
| ) | ||
| expect_error( | ||
| lyt |> build_table(ex_adsl, alt_counts_df = DM), | ||
| "alt_counts_df appears incompatible with column-split*" | ||
|
|
@@ -384,3 +377,31 @@ test_that("full alt_counts_df is accessible from afun/cfun via .alt_df_full", { | |
| cvals <- unlist(cell_values(tbl)) | ||
| expect_true(all(cvals == "ok")) | ||
| }) | ||
|
|
||
| test_that(".alt_df* argument behavior is correct when alt_counts_df is not set", { | ||
| check_alt_dfs <- function(df, .df_row, .alt_df_row, .alt_df, .alt_df_full) { | ||
| expect_identical(df, .alt_df) | ||
| expect_identical(.df_row, .alt_df_row) | ||
| expect_false(is.null(.alt_df_full)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice test. One thing, here we only check |
||
| TRUE | ||
| } | ||
|
|
||
| afun <- function(df, .df_row, .alt_df_row, .alt_df, .alt_df_full) { | ||
| res <- check_alt_dfs(df, .df_row, .alt_df_row, .alt_df, .alt_df_full) | ||
| in_rows("afun result" = "OK") | ||
| } | ||
| cfun <- function(df, labelstr, .df_row, .alt_df_row, .alt_df, .alt_df_full) { | ||
| res <- check_alt_dfs(df, .df_row, .alt_df_row, .alt_df, .alt_df_full) | ||
| in_rows("cfun result" = "OK", .formats = list("cfun result" = "xx")) | ||
| } | ||
|
|
||
| first_2_levs <- function(vec) levels(vec)[1:2] | ||
|
|
||
| lyt <- basic_table() |> | ||
| split_cols_by("ARM", split_fun = keep_split_levels(first_2_levs(ex_adsl$ARM))) |> | ||
| split_rows_by("STRATA1", split_fun = keep_split_levels(first_2_levs(ex_adsl$STRATA1))) |> | ||
| summarize_row_groups("STRATA1", cfun = cfun) |> | ||
| analyze("AGE", afun = afun) | ||
|
|
||
| expect_no_error(build_table(lyt, ex_adsl)) | ||
| }) | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmbecker small thing on the version here,I checked the tags and the
stop()was actually still inv0.6.16, it is only being removed in this PR. So<= 0.6.13is not right, it should point to the last release before this fix (0.6.16) or just say "in previous versions" to be safe. Also there is a double space and the closing}got glued onto the sentence (error. }), and this paragraph is sitting inside the\describe{}block, so it will render as a weird list item. I would move it out just after the closing brace so it reads as body text.