Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

289 possibility to pass custom axis label for g_lineplot and g_sphagettiplot #259

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion R/g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ g_lineplot <- function(label = "Line Plot",

gtitle <- paste0(biomarker1, unit1, stringr::str_to_title(line), " by Treatment @ Visits")
gylab <- paste0(biomarker1, " ", stringr::str_to_title(line), " of ", value_var, " Values")
gxlab <- if (is.null(attr(data[[time]], "label"))) time else attr(data[[time]], "label")

# Setup legend label
trt_label <- `if`(is.null(attr(data[[trt_group]], "label")), "Dose", attr(data[[trt_group]], "label"))
Expand Down Expand Up @@ -463,7 +464,7 @@ g_lineplot <- function(label = "Line Plot",
"For median, the bar denotes the first to third quartile.\n",
caption_loqs_label
)) +
ggplot2::xlab(time) +
ggplot2::xlab(gxlab) +
ggplot2::ylab(gylab) +
ggplot2::theme(
legend.box = "vertical",
Expand Down
2 changes: 1 addition & 1 deletion R/g_spaghettiplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ g_spaghettiplot <- function(data,


xtype <- ifelse(is.factor(data[[time]]) | is.character(data[[time]]), "discrete", "continuous")
gxlab <- if (is.null(attr(data[[time]], "label"))) time else attr(data[[time]], "label")
m7pr marked this conversation as resolved.
Show resolved Hide resolved
if (xtype == "discrete") {
data[[time]] <- if (!is.null(time_level)) {
factor(data[[time]], levels = time_level)
Expand All @@ -280,7 +281,6 @@ g_spaghettiplot <- function(data,
unique() %>%
magrittr::extract2(1)
gtitle <- paste0(biomarker1, unit1, " Values by Treatment @ Visits")
gxlab <- if (is.null(attr(data[[time]], "label"))) time else attr(data[[time]], "label")
gylab <- paste0(biomarker1, " ", value_var, " Values")

# Setup legend label
Expand Down
Loading