Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a288a58
Fix duplicated x scale and expose cap width in PK line plots (#322)
Melkiades Sep 29, 2026
e40e2c6
Dodge PKC error bars and drop misleading factor-encouragement message
wzfrank Oct 5, 2026
62d0bf7
Merge branch 'main' into 322_pkc_lineplot_x_scale_and_caps@main
wzfrank Oct 5, 2026
a9d87c4
Add gg_pkc_boxplot() for PK concentration box plots
wzfrank Oct 6, 2026
70f8bd1
Fix spellcheck flag and R CMD check NOTE in gg_pkc_boxplot()
wzfrank Oct 6, 2026
b2071b7
Reword percentile whisker description to avoid ordinal suffix
wzfrank Oct 6, 2026
1708f62
Sync generated Rd files with CI's roxygen2 output
wzfrank Oct 6, 2026
069e46e
Add gg_pkc_boxplot to pkgdown reference index
wzfrank Oct 6, 2026
b36f05b
Add percentiles parameter and warn on log-scale filtering in gg_pkc_b…
wzfrank Oct 7, 2026
e168211
Add dodge_width to gg_pkc_lineplot() and improve gg_pkc_boxplot()
wzfrank Oct 7, 2026
1011bd3
Fix gg_pkc_lineplot.Rd link target for CI's roxygen2 8.1.0
wzfrank Oct 8, 2026
4263eaa
Use whisker-specific ARD stat names and add id_var for outlier tracea…
wzfrank Oct 12, 2026
4c82ccb
Merge remote-tracking branch 'origin/main' into 322_pkc_lineplot_x_sc…
wzfrank Oct 12, 2026
953e1d1
Use variability-specific ARD stat names in gg_pkc_lineplot
wzfrank Oct 12, 2026
f419f91
[skip ci] Add sd to WORDLIST
wzfrank Oct 12, 2026
04f5700
[skip ci] Whitespace alignment cleanup
wzfrank Oct 12, 2026
46adc14
Trigger CI
wzfrank Oct 12, 2026
2067888
Use stats::sd() in ARD stat list to fix R CMD check NOTE
wzfrank Oct 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export(get_mmrm_results)
export(gg_km)
export(gg_lineplot)
export(gg_mmrm_lineplot)
export(gg_pkc_boxplot)
export(gg_pkc_lineplot)
export(label_roche_number)
export(label_roche_percent)
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

# crane 0.4.0

* Added `gg_pkc_boxplot()` to plot Pharmacokinetic concentrations as box plots, with a selectable whisker method (`"percentile"`, `"tukey"`, or `"minmax"`), outlier detection, and an optional mean marker. (#322)

* `gg_pkc_lineplot()` now adds a single x scale instead of two, so it no longer reports "Scale for x is already present" on every call with a numeric `time_var`. The `expand` setting that the discarded scale carried is now applied. (#322)

* `gg_pkc_lineplot()` gains an `x_breaks` argument to set the breaks of a numeric x-axis, for time ranges too wide to label every timepoint. The default `NULL` keeps a break on every observed timepoint. (#322)

* `gg_pkc_lineplot()` and `gg_lineplot()` gain an `errorbar_width` argument to set the width of the error bar caps, previously fixed at `0.45`. (#322)

* `modify_split_caption()` now errors when given a table that was never split, instead of silently returning it unchanged. A plain table has no split level to build a subtitle from; the message points at `split_by_rows = list(variable_level = ...)`. Pages of a row-number split are still skipped silently, as before. (#318)

* Added `add_label_column()` to split a `{gtsummary}` table's row labels into a new left label column (`label0`) and the existing `label` column, computing the new column from an expression evaluated in the table body. This is the `strata_location = "new_column"` layout of `tbl_shift()` exposed as a standalone step for nested count and shift tables. (#314)
Expand Down
22 changes: 8 additions & 14 deletions R/gg_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#' Horizontal jitter width applied to points, lines and error bars together
#' so they stay aligned. `0` (default) disables jittering and uses dodging
#' only. A small value such as `0.1` helps separate overlapping groups.
#' @param errorbar_width (`numeric`)\cr
#' Width of the horizontal caps on the variability error bars. Default is
#' `0.45`. Set to `0` for no caps. Ignored when `variability = "none"`.
#'
#' @return A `ggplot` object of class `crane_gg_line`.
#'
Expand Down Expand Up @@ -92,7 +95,8 @@ gg_lineplot <- function(data,
variability = c("ci", "sd", "se", "iqr", "none"),
conf_level = 0.95,
show_n = FALSE,
jitter = 0) {
jitter = 0,
errorbar_width = 0.45) {
# 1. Argument Matching and Validation
stat <- match.arg(stat)
variability <- match.arg(variability)
Expand Down Expand Up @@ -121,9 +125,8 @@ gg_lineplot <- function(data,
group = {{ group }}
)

# change from factor to numeric
# x can be factor or numeric - factor allow for correct n of decimals
# in the summary table
# x can be supplied as factor or numeric; convert factor to numeric when
# possible, otherwise keep it as a factor for discrete plotting
if (!is.numeric(data[[x]])) {
# 1. "Test" the conversion silently to see if it results in NAs
test_numeric <- suppressWarnings(as.numeric(as.character(data[[x]])))
Expand All @@ -138,15 +141,6 @@ gg_lineplot <- function(data,
c("i" = "Categorical X-axis detected. Leaving as factor for discrete plotting.")
)
}
} else {
cli::cli_inform(
c(
"i" = paste0(
"We encourage to supply `x` as a factor, since it supports ",
"correct decimals formatting in the summary table."
)
)
)
}

# 2. Data Preprocessing
Expand Down Expand Up @@ -219,7 +213,7 @@ gg_lineplot <- function(data,
# 4. Add Variability Layer conditionally to avoid drawing degenerate lines
if (variability != "none") {
p <- p |>
gg_add_stats(stat, variability, conf_level, position = pd)
gg_add_stats(stat, variability, conf_level, position = pd, width = errorbar_width)
}

# 5. Theming
Expand Down
Loading
Loading