-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
bugSomething isn't workingSomething isn't workingissueUsed for project filteringUsed for project filtering
Description
Issue description
In theory, attrition diagrams accommodate arbitrary column names for value_column_name, so long as they are valid columns in the attrition table object. But string formatting prevents attrition diagrams from printing percentages, even when they are the pre-calculated format from the get_attrition function.
Steps to reproduce the issue
Minimal reproducible code below. Note that changing value_column_name from "Remaining %" to "Remaining N" produces a diagram as expected.
ad <- visR::get_attrition(visR::adtte,
criteria_descriptions = c("1. Not in Placebo Group",
"2. Be 75 years of age or older.",
"3. White",
"4. Female"),
criteria_conditions = c("TRTP != 'Placebo'",
"AGE >= 75",
"RACE=='WHITE'",
"SEX=='F'"),
subject_column_name = "USUBJID")
visR::visr(ad, description_column_name = "Criteria", value_column_name = "Remaining %")What's the expected result?
An attrition diagram that reports included and excluded patients in terms of percentage of the initial study population.
What's the actual result?
No diagram is produced, and I get the following error message:
Error: Problem with `mutate()` column `label`.
ℹ `label = sprintf("%s\nN = %d", label, get(value_column_name))`.
x invalid format '%d'; use format %f, %e, %g or %a for numeric objects
ℹ The error occurred in row 2.
Additional details / screenshot
I believe the problem arises from applying the following sprintf within the .get_labels internal:
dplyr::mutate(label = sprintf("%s\nN = %d", label, get(value_column_name)))
Solution ideas
- Allow users to specify their own
sprintftemplate tovisr.attrition, perhaps with"%s\nN = %d"as the default - Within
.get_labels, check whethervalue_column_namecontains integers, and apply N-based labelling if so and %-based labelling (e.g.,"%s\n%.2f%%") otherwise
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingissueUsed for project filteringUsed for project filtering
