vignettes/articles/llm-use.Rmd)
saying which AI coding assistants were used, for what, and how their output
was checked. It is linked from the home-page sidebar and every page footer.as_narrative() writes the attrition cascade as a paragraph for a
methods section: "Of 200 participants assessed for eligibility, 16 (8.0%)
were excluded: age missing (n = 10) and under 18 (n = 6). ..." The numbers
come from as_attrition_tibble(), and after a randomise() step from the
same per-arm counts as as_consort_diagram(), so the text agrees with the
table and diagram. There is one sentence per category (or per step), each
step described by its reason (an inclusion step without one reads
not meeting "<label>"), per-arm sentences after randomisation, and a
final-cohort sentence broken down by arm. count_by counts units as in the
table; unit sets the noun; style = "bullets" gives one sentence per
line. The result prints wrapped to the console and drops into R Markdown
and Quarto documents as text.exclude() or group_exclude() step's label now
appears in its exclusion box with the number removed ("Withdrew consent
(n=4)"), and the main box below it reads "Remaining (n=118)". Previously
the main box showed "Withdrew consent (n=118)", which read as 118
withdrawals. The new remaining_label argument changes that text.
include()-type steps keep their label on the main box.count_by now counts distinct units in every box and row, not only the
arm boxes and columns. In as_attrition_tibble(), as_attrition_table()
and as_consort_diagram(), n, n_removed and the percentages all count
units, so a crossover trial reports participants throughout instead of
participant-periods in the trunk and participants in the arms. A unit
counts as removed at the step where it loses its last row. count_by must
name a level of the flow's hierarchy (a level name, or the column of a
single-column level), so the flow needs apply_criteria(hierarchy = ).
Old calls without a hierarchy, or naming a column that is not a level,
fail with an error (class cohortflow_count_by_hierarchy) that explains
the change and shows the cf_hierarchy() call to add.include(), exclude(), group_include(), group_exclude(),
select_within() and cf_criterion() gain reason: a description of the
rows the step removes ("Under 18" for include(~ age >= 18, "Aged 18 or over")). Diagram exclusion boxes use it. Exclusion steps default to their
label. An inclusion step without one gets an exclusion box that says
"Excluded". If it is listed in a category's exclusion box, its label is
used and as_consort_diagram() warns (class cohortflow_missing_reason,
at most every 8 hours; options(cohortflow.warn_missing_reason = FALSE)
turns it off). reason is printed with the pipeline and round-trips
through export_criteria() / import_criteria(); it is written only when
set, so other files are unchanged. Flows built before reason existed
still draw.count_by no longer requires branch_by, and works with a randomise()
split (each arm's cascade counts the same units as the trunk).steps = c(0, "Consented") turns 0 into the
text "0", which matches no step. The error now says so and suggests
list(0, "Consented"). This applies wherever steps are selected
(cohort(), excluded(), as_characteristics_tibble(),
stack_cohorts()). A step labelled "1" still resolves by label.import_criteria() warns (class cohortflow_legacy_yaml) when a file
uses the pre-0.0.0.9011 fn_args format, naming the step, explaining
that default argument values were not stored, and giving the call to
re-save the file. A file with a schema version newer than 1 is refused
with a message to update the package, instead of being misread.mock_cohortflow() deprecation warning lists which generator suits
which design, and has class cohortflow_deprecated.include() and exclude() treat missing values) and
"Hierarchical and cluster designs".export_criteria(),
import_criteria(), plot.cf_flow() and print.consort_diagram() gain
examples.as_consort_diagram(stage_by = ) no longer draws stage boxes on top of
each other. Stages (e.g. crossover periods) now stack below their branch
box with the same gap as the rest of the diagram, and a wrapped label
pushes later stages down instead of overlapping them.as_attrition_table() and as_characteristics_table()
now leaves empty cells blank, as flextable and huxtable do. Previously it
printed NA in the header row's removed count and in every arm column
above the final row.as_attrition_table(levels = NULL) now shows every hierarchy level, as
documented and as as_attrition_tibble(levels = NULL) does. Previously it
failed with an internal subsetting error.excluded() gains only = FALSE. With only = TRUE it returns just the
rows removed at the selected step, rather than every row removed up to and
including it: excluded(flow, at = 2, only = TRUE).save_consort_diagram() writes a CONSORT diagram (or a cf_flow, drawn
with default settings) to PNG, TIFF, JPEG, PDF, SVG or EPS, choosing the
format from the file extension. Defaults suit manuscript submission:
300 dpi, a white background, ragg devices for raster output when
installed, cairo_pdf() for PDF (embeds fonts), and svglite for SVG
when installed. When width and height are omitted the page size comes
from the diagram layout, so box text fits its boxes and longer pipelines
give taller files; supplying one dimension keeps the aspect ratio.as_attrition_table() now shows every percentage to digits decimal
places, keeping trailing zeros: a 10% removal reads 10.0% rather than
10%, and the final row 90.0% included. This applies to plain,
group_x/group_y and levels = tables, matching
as_consort_diagram().as_characteristics_tibble() and as_characteristics_table() build a
step-wise baseline-characteristics ("Table 1") table: variables as rows,
one column per criteria step, each cell summarising the cohort surviving
up to and including that step (cohort(flow, step_number = k)). Numeric
variables show mean (SD) and/or median [Q1, Q3]; factor, character and
logical variables show n (%); each variable gets a missing-values row.
steps = takes the same selectors as cohort() to restrict or reorder the
columns, excluded = TRUE describes the rows removed at each step
instead, and level = summarises one row per hierarchy unit. The table
renders through the same flextable, gt and huxtable backends as
as_attrition_table().stack_cohorts() returns the per-step cohorts stacked with a step
factor, ready for gtsummary::tbl_summary(by = step).cf_criterion() and the criterion evaluators no longer
show raw markup such as {.arg label}; they now include the actual label,
class, lengths and missing column names.as_attrition_tibble(levels = ),
as_attrition_table(levels = )) no longer count an NA key as a unit.
For example, an expected participant with no cluster counts as one
participant and zero clusters, not as an extra "phantom" cluster..data and .env pronouns now work in include(), exclude() and
select_within() formulas, as they already did in grouped steps and as
check_criteria() assumed.export_criteria() no longer errors on a primitive-function predicate such
as include(is.na, ...). Such predicates now print as .Primitive("is.na")
rather than NULL.as_attrition_tibble(), as_attrition_table() and as_consort_diagram()
now give a clear error ("branch_by must be a single column name.") when
branch_by, count_by, stage_by, stage_label_by, group_x or
group_y is not a single column name. Previously this failed with an R
internals error.as_consort_diagram() now draws a plain linear cascade when no rows reach
the branch point (a zero-row flow, or every row excluded before
randomise()). Previously it warned, or with branch_by failed.group_include() / group_exclude() (e.g.
~ age > 18) now gives "Group criterion "NA values in branch_by / stage_by (including randomise() arms) now
form their own branch, labelled by the new branch_na_label argument
(default "Missing") of as_attrition_tibble(), as_attrition_table()
and as_consort_diagram(). Previously they were counted in every branch.apply_criteria() now aborts (instead of warning) when the row identifier
(id, single or composite, or a pre-existing .cf_row_id) has duplicate
or NA values, which silently corrupted cohort() / excluded()..pass, the by column(s), and
exactly one row per group; anything else now aborts.NA in any by column are removed by every grouped step type
(group_exclude() used to keep them).as_attrition_table() gains group_na_label.x$predicate.export_criteria() stores the full function source, so default argument
values survive a YAML round-trip; the fn_args field is dropped (old files
still import). It now returns the YAML visibly when path = NULL.
import_criteria() documents that criteria files contain executable code.NaN% included.branch_by values that clash with standard column names (e.g. "n")
abort.NA branch column is removed from as_attrition_tibble()
output.cf_criterion() aborts when by is given for include / exclude;
as_consort_diagram() aborts when count_by is given without
branch_by.mock_cohortflow() warns once per session.cohort() and excluded() can stop at an intermediate step, returning the
rows surviving (or removed) up to and including it. Select the step with
step_number (0 = starting data), label, or category (last step in
that category); or use at, which auto-selects (number, else label, else
category). At most one selector may be given. With cohort(flag = TRUE),
attribution only covers steps up to the chosen step.
New criteria_status() returns one row per data row and one logical column
per criterion, for auditing who failed what and for set/overlap plots of
exclusion reasons. mode = "cumulative" follows the cascade (FALSE at the
removing step, NA = not assessed afterwards); mode = "independent"
evaluates every criterion on the full data. Options cover failure sets
(sets = "fail"), NA handling (na = "keep"/"false"/"drop"), column
naming, keep_data, and output as a tibble, data.table or logical matrix.
data.table is a new suggested package.
New check_criteria(criteria, data) checks before evaluation that every
formula predicate, by and arms refers only to columns in data, and
aborts naming each offending step's number, label and missing column(s).
apply_criteria() and continue_criteria() run it automatically, so a
forgotten join in a staged pipeline now fails up front instead of with
object 'x' not found inside evaluation. Names bound in the formula's
environment are allowed; function predicates are not checked.
cf_flow objects record the id column(s) passed to apply_criteria()
(older flow objects still work).
?include / ?exclude document how a predicate that evaluates to NA is
handled: include() removes the row, exclude() keeps it.
as_attrition_table() gained a levels argument, mirroring
as_attrition_tibble(levels = ): it renders one row per criterion with a
column block (N / Removed / % removed) per hierarchy level, so a single
row reports its effect at both the unit of analysis and the unit of
recruitment (e.g. participants and clusters) side by side. This is the
reporting form required by the CONSORT cluster extension (Campbell,
Elbourne & Altman, BMJ 2004;328:702-8) and the within-person extension.
New level_labels argument supplies display names for the column blocks
(level names are otherwise used as-is, unmangled). A show_consequential
argument adds an optional fourth column per level for units lost only
because a group_include()/group_exclude() group they belonged to was
removed; by default it appears only when populated. levels cannot be
combined with group_x/group_y/branch_by/count_by. Shading
(shade/shade_fn) is computed per level.