Skip to content

Commit 0c0bb5b

Browse files
committed
Tooltip labels generated dynamically
1 parent 9983eee commit 0c0bb5b

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ dev_local/Dockerfile_bu
7373
/man
7474
peak_detection_windows_dynamic.html
7575
/peak_detection_windows_dynamic_files
76+
docs/goodpractice-remediation-plan.md

R/peak-detection-windows-dynamic.R

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ peak_detection_windows_dynamic <- function(
274274
sort(unique(as.character(.data$condition_id))),
275275
collapse = ", "
276276
),
277+
n = n(),
277278
.groups = "drop"
278279
) |>
279280
# Build a readable axis label from the exact SCR scoring-window definition
@@ -300,7 +301,8 @@ peak_detection_windows_dynamic <- function(
300301
cols = -all_of(c(
301302
"scr_scoring_approach",
302303
"condition_ids_per_scoring",
303-
"scoring_window_definition"
304+
"scoring_window_definition",
305+
"n"
304306
)),
305307
names_to = c("measure", "window", "timepoint"),
306308
names_pattern = "(scr)_(.*)_window_(.*)"
@@ -345,7 +347,14 @@ peak_detection_windows_dynamic <- function(
345347
factor(levels = c("Baseline", "Peak Detection", "Trough Detection"))
346348
) |>
347349
# Only complete numeric intervals can be drawn as geom_segment() rows.
348-
tidyr::drop_na(all_of(c("start", "end")))
350+
tidyr::drop_na(all_of(c("start", "end"))) |>
351+
mutate(
352+
condition_ids_per_scoring = if_else(
353+
n == 1,
354+
paste("Dataset ID:", condition_ids_per_scoring),
355+
paste("Dataset IDs:", condition_ids_per_scoring)
356+
)
357+
)
349358

350359
# Supported columns can still produce no plottable rows if all endpoint values
351360
# were missing or non-numeric, so give a data-quality error before ggplot.
@@ -475,7 +484,7 @@ peak_detection_windows_dynamic <- function(
475484
yend = .data$end,
476485
color = .data$window,
477486
group = .data$window,
478-
tooltip = paste("Dataset ID(s):", .data$condition_ids_per_scoring),
487+
tooltip = .data$condition_ids_per_scoring,
479488
data_id = .data$plot_group
480489
),
481490
linewidth = segment_linewidth

0 commit comments

Comments
 (0)