• Added diff_ard_hierarchical(), which calculates the difference in event rates (the p statistic) between two groups of a stacked hierarchical ARD created with ard_stack_hierarchical(), returning the result under a new "estimate" statistic. When there is a single by variable with two levels the difference defaults to the first level minus the second; otherwise the two groups are specified via the levels argument.

  • ARDs now print through the pillar/tibble machinery: the header reads An ARD data frame, columns show their names and classes, and scalar list-column elements print their value (falling back to the standard tibble summary such as <chr [2]>, <fn>, and <NULL> for non-scalars). When the output is too wide for the console, all-NULL error and warning columns are dropped first, then fmt_fun, stat_label, stat_fmt, and context, before the standard tibble column shrinking; suppressed columns are listed in the footer. as_card() now always returns a tibble so that every ARD prints this way.

  • Removed the deprecated handling of dplyr::vars() in selecting environments (cards_select()), along with the vars() re-export. Use c() instead.

  • Added the by_level argument to sort_ard_hierarchical(), allowing "descending" sorting to rank variable groups by the counts observed within specific by variable levels (e.g. by_level = list(TRTA = "Placebo")) rather than the sums across all by variable levels. The argument accepts a named list, so any combination of by variables may be used. (#548, @rikoprogrammer)

  • Reduced the run time and memory use of sort_ard_hierarchical() and filter_ard_hierarchical(), particularly for ARDs with many hierarchy sections. The per-level grouped sums, the group-wise filter loop (including the previously per-group tidyr::pivot_wider() for column statistics and the per-group join used to derive the _overall statistics), the reformatting helper, and the empty-section pruning were all replaced with vctrs-based equivalents. Because sort_ard_hierarchical() also runs inside ard_stack_hierarchical(), this speeds up ARD construction as well. Results are unchanged. (#176)

  • Further reduced the run time and memory use of ard_stack_hierarchical() and ard_stack_hierarchical_count(), primarily by replacing the per-level dplyr::slice_tail() de-duplication with a vctrs-based equivalent and by avoiding unnecessary coercions of data frame denominators. Results are unchanged. (#176)

  • Reduced the run time and memory use of ard_tabulate() (and the functions built on it) for results with many rows, by vectorizing the assignment of the default statistic labels. Results are unchanged. (#176)

  • ard_tabulate() — and the functions built on it (ard_tabulate_value(), ard_tabulate_rows(), ard_hierarchical(), ard_hierarchical_count(), ard_stack(), ard_stack_hierarchical()) — now uses a rewritten sparse single-pass counting engine, substantially reducing run time and memory use for data with many strata combinations or high-cardinality variables. The data is tabulated once per variable, and the column/row/cell/integer denominators are derived from the same counts. (#176)

    Results are otherwise unchanged — including value types and row ordering — with these exceptions:

    • The internal message beginning “If you see this message, the order of the sorted variables in the tabulation is unexpected” has been removed along with the code path that triggered it; inputs that previously hit it (e.g. NaN in a by column) are now handled correctly.
    • Zero-row data with strata, and an empty statistic vector, previously errored with internal errors; both now return an empty ARD.
  • Character values are now sorted in the C locale throughout the package (via order(method = "radix")), so the ordering of variable and group levels no longer depends on the session locale and is consistent with dplyr::arrange(). Previously, character variable/by levels were sorted in the session locale (base::sort()) while strata levels already used dplyr::arrange(); these now agree. This affects ard_tabulate(), ard_summary(), ard_pairwise(), ard_tabulate_value() (via maximum_variable_value()), and related functions, and differs from prior releases only for locale-sensitive character values (mixed case, punctuation).

New Features and Functions

Other Updates

Bug Fixes

New Features and Functions

  • Updated sort_ard_hierarchical() to allow for different sorting methods at each hierarchy variable level. (#487)

  • Updated sort_ard_hierarchical() and filter_ard_hierarchical() to always keep attribute and total N rows at the bottom of the ARD.

  • Added argument var to filter_ard_hierarchical() to allow filtering by any hierarchy variable. (#467)

  • Added flexibility to filter by by variable level-specific values when using filter_ard_hierarchical() to allow for filtering of hierarchical ARDs by difference in two rates. (#438)

  • The ard_strata() function has been updated to include the strata columns in the nested data frames. (#461)

  • Similar to ard_stack_hierarchical(), ard_stack() contains an args attribute to retain information about input arguments.

  • Added an article illustrating how to summarize long data structures. (#356)

  • Added ard_stack(.by_stat) and ard_stack_hierarchical(by_stat) arguments that, when TRUE (the default), includes a univariate ARD tabulation of the by variable in the returned ARD. (#335)

  • shuffle_ard() passes down the args attribute of the input card object when present. (#484, @dragosmg)

  • shuffle_ard() fills overall or group statistics with "Overall <column_name>" or "Any <column_name>". (#337, @dragosmg)

  • shuffle_ard() messages if "Overall <column_names>" is accidentally present in the data and creates a unique label. (#465, @dragosmg)

  • Add ADLB data set. (#450)

Lifecycle Changes

New Features and Functions

  • Added new function ard_identity() for saving pre-calculated statistics in an ARD format. (#379)

Lifecycle Changes

  • Updating any fmt_fn references to fmt_fun for consistency.

    • Any function with an argument cards::foo(fmt_fn) has been updated to cards::foo(fmt_fun). The old syntax will continue to function, but with a deprecation warning to users.

    • The following function names have been updated: alias_as_fmt_fun(), apply_fmt_fun(), and update_ard_fmt_fun(). The former function names are still exported from the package, and users will see a deprecation note when they are used.

    • Importantly, the ARD column named "fmt_fn" has been updated to "fmt_fun". This change cannot be formally deprecated. For users who were accessing the ARD object directly to modify this column instead of using functions like update_ard_fmt_fun(), this will be a breaking change.

Bug Fixes

New Features and Functions

Bug Fixes

Lifecycle Changes

  • The shuffle_ard() function no longer outputs a 'label' column, and instead retains the original 'variable' level from the cards object. It also no longer trims rows with non-numeric stats values. (#416)
  • Small update to account for a change in R-devel.

New Features and Functions

  • Added functions rename_ard_groups_shift() and rename_ard_groups_reverse() for renaming the grouping variables in the ARD. (#344)

  • Added an option to specify the default rounding in the package: cards.round_type. See ?cards.options for details. (#384)

  • Added the print_ard_conditions(condition_type) argument, which allows users to select to return conditions as messages (the default), or have warnings returned as warnings and errors as errors. (#386)

  • Added the all_ard_group_n(types) argument to allow separate selection of groupX and groupX_level columns.

  • Added the tidy_ard_column_order(group_order) argument that allows users to specify whether the grouping variables are listed in ascending order (the default) or descending order. The output of ard_strata() now calls tidy_ard_column_order(group_order="descending").

Other Updates

  • A new article has been added detailing how to create new ARD functions.

  • Results are now sorted in a consistent manner, by descending groups and strata. (#342, #326)

Lifecycle Updates

  • Function label_cards() has been renamed to label_round(), which more clearly communicates that is returns a rounding function.

New Features and Functions

Other Updates

  • Improved messaging in print_ard_conditions() when the calling function is namespaced. (#348)

  • Updated print method for 'card' objects so extraneous columns are never printed by default.

Lifecycle Changes

  • No longer exporting functions check_pkg_installed(), is_pkg_installed(), get_min_version_required(), get_pkg_dependencies(). These functions are now internal-only. (#330)

Bug Fixes

  • The tidy_ard_column_order() now correctly orders grouping columns when there are 10+ groups. This also corrects an issue in the hierarchical functions where the ordering of the variables matters. (#352)

New Features & Updates

Other Updates

  • The ard_hierarchical_count() function has been updated to match the behavior of ard_hierarchical() and results are now only returned for the last column listed in the variables arguments, rather than recursively counting all variables.

  • Add columns 'fmt_fn', 'warning', and 'errors' to ard_attributes() output. (#327)

  • Add checks for factors with no levels, or any levels that are NA into ard_* functions (#255)

  • Any rows with NA or NaN values in the .by columns specified in ard_stack() are now removed from all calculations. (#320)

New Features & Updates

  • Converted ard_total_n() to an S3 generic and added method ard_total_n.data.frame().

  • Added the bind_ard(.quiet) argument to suppress messaging. (#299)

  • Improved ability of shuffle_ard() to populate missing group values where possible. (#306)

  • Added apply_fmt_fn(replace) argument. Use replace=FALSE to retain any previously formatted statistics in the stat_fmt column. (#285)

  • Added bind_ard(.distinct) argument, which can remove non-distinct rows from the ARD across grouping variables, primary variables, context, statistic name and value. (#286)

Bug Fixes

  • Update in ard_categorical() to use base::order() instead of dplyr::arrange(), so the ordering of variables match the results from base::table() in some edge cases where sorted order was inconsistent.

  • Update in ard_categorical() to run base::table() output checks against coerced character columns. Previously, we relied on R to perform checks on the type it decided to check against (e.g. when it coerces to a common type). While the initial strategy worked in cases of Base R classes, there were some bespoke classes, such as times from {hms}, where Base R does not coerce as we expected.

  • Adding selectors all_group_n() and all_missing_columns(). (#272, #274)

  • Added new function add_calculated_row() for adding a new row of calculated statistic(s) that are a function of the other statistics in the ARD. (#275)

New Features & Updates

  • Converting ard_*() functions and other helpers to S3 generics to make them extendable. (#227)

  • Added helper rename_ard_columns() for renaming/coalescing group/variable columns. (#213).

  • Added new function ard_total_n() for calculating the total N in a data frame. (#236)

  • Added the nest_for_ard(include_data) argument to either include or exclude the subsetted data frames in a list-column in the returned tibble.

  • Added check_ard_structure(column_order, method) arguments to the function to check for column ordering and whether result contains a stat_name='method' row.

  • Added the optional ard_hierarchical(id) argument. When provided we check for duplicates across the column(s) supplied here. If duplicates are found, the user is warned that the percentages and denominators are not correct. (#214)

  • Improved messaging in check_pkg_installed() that incorporates the calling function name in the case of an error. (#205)

  • Updated is_pkg_installed() and check_pkg_installed() to allow checks for more than package at a time. The get_min_version_required() function has also been updated to return a tibble instead of a list with attributes. (#201)

  • Styling from the {cli} package are now removed from errors and warnings when they are captured with eval_capture_conditions(). Styling is removed with cli::ansi_strip(). (#129)

Bug Fixes

  • Bug fix in ard_stack() when calls to functions were namespaced. (#242)

  • The print_ard_conditions() function has been updated to no longer error out if the ARD object does not have "error" or "warning" columns. (#240)

  • Bug fix in shuffle_ard() where factors were coerced to integers instead of their labels. (#232)

Lifecycle Changes

  • Corrected order that ard_categorical (strata) columns would appear in the ARD results. Previously, they appeared in the order they appeared in the original data, and now they are sorted properly. (#221)

  • The API for ard_continuous(statistic) and ard_missing(statistic) arguments has been updated. Previously, the RHS of these argument’s passed lists would be either continuous_summary_fns() and missing_summary_fns(). Now these arguments accept simple character vectors of the statistic names. For example, ard_categorical(statistic = everything() ~ c("n", "p", "N")) and ard_missing(statistic = everything() ~ c("N_obs", "N_miss", "N_nonmiss", "p_miss", "p_nonmiss")). (#223)

  • Updated ard_stack() to return n, p, and N for the by variable when specified. Previously, it only returned N which is the same for all levels of the by variable. (#219)

  • Bug fix where ard_stack(by) argument was not passed to ard_missing() when ard_stack(.missing=TRUE). (#244)

  • The ard_stack(by) argument has been renamed to ".by" and its location moved to after the dots inputs, e.g. ard_stack(..., .by). (#243)

  • A messaging overhaul to utilize the scripts in https://github.com/ddsjoberg/standalone/blob/main/R/standalone-cli_call_env.R. This allows clear error messaging across functions and packages. (#42)

    • The print_ard_conditions(call), check_list_elements(env), cards_select(.call) arguments have been removed.
  • Initial release.