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

arbitrary horizontal lines to tm_g_gh_spaghettiplot #41

Merged
merged 28 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
270f60a
initial fix to accommodate API change to goshawk
denisovan31415 Sep 9, 2021
cf41f4c
new select input to spaghettiplot module for horizontal lines
denisovan31415 Sep 9, 2021
148e7bc
NEWS
denisovan31415 Sep 9, 2021
f53799d
hline
denisovan31415 Sep 9, 2021
a83546d
re labeling and moving ui
denisovan31415 Sep 9, 2021
53bf300
indentation
denisovan31415 Sep 9, 2021
8c72da7
added arbitrary line label to legend
denisovan31415 Sep 9, 2021
c757587
Merge branch 'main' into 39_arb_hori_lines_spaigeitti@main
denisovan31415 Sep 10, 2021
b0ddb6d
removed unused hline parameter
denisovan31415 Sep 10, 2021
f7f0fe4
fixed empty group stat lable
denisovan31415 Sep 10, 2021
0eda77e
fixed name reference bug
denisovan31415 Sep 10, 2021
de49425
added hline_arb_color argument
denisovan31415 Sep 13, 2021
782c623
working roxygen APP with the ANRLO and ANRHI horizontal lines
denisovan31415 Sep 14, 2021
e23cc5f
docs
denisovan31415 Sep 14, 2021
a5ecb4a
fixed mass pasting error
denisovan31415 Sep 14, 2021
be9d75c
docs
denisovan31415 Sep 14, 2021
285a902
Merge branch 'main' into 39_arb_hori_lines_spaigeitti@main
denisovan31415 Sep 14, 2021
beab50e
argument reorder
denisovan31415 Sep 14, 2021
a5c3fe9
Update R/tm_g_gh_spaghettiplot.R
denisovan31415 Sep 14, 2021
fabe01f
Update R/tm_g_gh_spaghettiplot.R
denisovan31415 Sep 14, 2021
fb3325f
docs
denisovan31415 Sep 14, 2021
b61ffb7
roxygen app comment bug
denisovan31415 Sep 14, 2021
945a6c5
reorder validation code
denisovan31415 Sep 14, 2021
1f42343
updated horizontal line section labels
npaszty Sep 14, 2021
414e4e4
fixed reproducible error in roxygen app
denisovan31415 Sep 15, 2021
3f9a550
docs
denisovan31415 Sep 15, 2021
31099d8
removed random numbers in roxygen app
denisovan31415 Sep 15, 2021
4dd7e35
Revert "removed random numbers in roxygen app"
denisovan31415 Sep 15, 2021
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 NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Update examples and document using `scda` synthetic data to replace `random.cdisc.data`.
* Updated license and `README.md` with appropriate information for migration to public Github.
* Added `error_on_lint: TRUE` to `.lintr`.
* Added another select input to `tm_g_gh_spaghettiplot` to add arbitrary horizontal lines to the plot.
* Fixed bug in `tm_g_gh_boxplot` module that always uses the `AVISITCD` variable as the `Visit` Column of the table.

# teal.goshawk 0.1.9
Expand Down
84 changes: 72 additions & 12 deletions R/tm_g_gh_spaghettiplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#' @param plot_width optional, controls plot width.
#' @param font_size control font size for title, x-axis, y-axis and legend font.
#' @param group_stats control group mean or median overlay.
#' @param hline_vars a character vector to name the columns that will define additional horizontal lines.
#' @param hline_vars_colors a character vector equal in length to hline_vars that will define the colors.
#' @param hline_vars_labels a character vector equal in length to hline_vars that will define the legend labels.
#' @inheritParams teal.devel::standard_layout
#'
#' @import goshawk
Expand Down Expand Up @@ -167,7 +170,27 @@ tm_g_gh_spaghettiplot <- function(label,
plot_width = NULL,
font_size = c(12, 8, 20),
pre_output = NULL,
post_output = NULL) {
post_output = NULL,
hline_vars = NULL,
hline_vars_colors = NULL,
hline_vars_labels = NULL) {

if (!is.null(hline_vars)) {
stopifnot(is_character_vector(hline_vars, min_length = 1))
if (!is.null(hline_vars_labels)) {
stopifnot(is_character_vector(
hline_vars_labels, min_length = length(hline_vars),
max_length = (length(hline_vars)))
)
}
if (!is.null(hline_vars_colors)) {
stopifnot(is_character_vector(
hline_vars_colors,
min_length = length(hline_vars),
max_length = (length(hline_vars)))
)
}
}

stopifnot(is.choices_selected(param))
stopifnot(is.choices_selected(xaxis_var))
Expand All @@ -194,7 +217,9 @@ tm_g_gh_spaghettiplot <- function(label,
xtick = xtick,
xlabel = xlabel,
plot_height = plot_height,
plot_width = plot_width
plot_width = plot_width,
hline_vars_colors = hline_vars_colors,
hline_vars_labels = hline_vars_labels
),
ui = g_ui_spaghettiplot,
ui_args = args,
Expand Down Expand Up @@ -229,7 +254,41 @@ g_ui_spaghettiplot <- function(id, ...) {
ns("group_stats"),
"Group Statistics",
c("None" = "NONE", "Mean" = "MEAN", "Median" = "MEDIAN"),
inline = TRUE),
inline = TRUE
),
if (!is.null(a$hline_vars)) {
optionalSelectInput(
ns("hline_vars"),
label = "Add Horizontal Range Line(s):",
choices = a$hline_vars,
selected = a$hline_vars[1],
multiple = TRUE)
},
div(
style = "display: flex",
div(
style = "padding: 0px;",
div(
style = "display: inline-block;vertical-align:moddle; width: 100%;",
tags$b("Line:")
),
div(
style = "display: inline-block;vertical-align:middle; width: 100%;",
numericInput(ns("hline"), "", a$hline)
)
),
gogonzo marked this conversation as resolved.
Show resolved Hide resolved
div(
style = "padding: 0px;",
div(
style = "display: inline-block;vertical-align:moddle; width: 100%;",
tags$b("Label:")
),
div(
style = "display: inline-block;vertical-align:middle; width: 100%;",
textInput(ns("hline_label"), "", "")
)
)
),
templ_ui_constraint(ns), # required by constr_anl_chunks
toggle_slider_ui(
ns("yrange_scale"),
Expand All @@ -247,12 +306,6 @@ g_ui_spaghettiplot <- function(id, ...) {
numericInput(ns("facet_ncol"), "", a$facet_ncol, min = 1))
),
checkboxInput(ns("rotate_xlab"), "Rotate X-Axis Label", a$rotate_xlab),
div(style = "padding: 0px;",
div(style = "display: inline-block;vertical-align:moddle; width: 175px;",
tags$b("Add a Horizontal Line:")),
div(style = "display: inline-block;vertical-align:middle; width: 100px;",
numericInput(ns("hline"), "", a$hline))
),
optionalSliderInputValMinMax(ns("font_size"), "Font Size", a$font_size, ticks = FALSE),
optionalSliderInputValMinMax(
ns("alpha"),
Expand Down Expand Up @@ -286,7 +339,9 @@ srv_g_spaghettiplot <- function(input,
xtick,
xlabel,
plot_height,
plot_width) {
plot_width,
hline_vars_colors,
hline_vars_labels) {
init_chunks()
# reused in all modules
anl_chunks <- constr_anl_chunks(
Expand Down Expand Up @@ -318,6 +373,7 @@ srv_g_spaghettiplot <- function(input,
param <- input$xaxis_param
xaxis_var <- input$xaxis_var
yaxis_var <- input$yaxis_var
hline_vars <- input$hline_vars
# nolint end
chunks_push(
chunks = private_chunks,
Expand All @@ -338,13 +394,17 @@ srv_g_spaghettiplot <- function(input,
color_comb = .(color_comb),
ylim = .(ylim),
facet_ncol = .(facet_ncol),
hline = .(`if`(is.na(hline), NULL, as.numeric(hline))),
hline_arb = .(`if`(is.na(hline), NULL, as.numeric(hline))),
hline_arb_label = .(input$hline_label),
xtick = .(xtick),
xlabel = .(xlabel),
rotate_xlab = .(rotate_xlab),
font_size = .(font_size),
alpha = .(alpha),
group_stats = .(group_stats)
group_stats = .(group_stats),
hline_vars = .(hline_vars),
hline_vars_colors = .(hline_vars_colors[seq_along(hline_vars)]),
hline_vars_labels = .(hline_vars_labels[seq_along(hline_vars)])
)
print(p)
})
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ggplot
gh
github
gshawk
hline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't have to add technical names in the wordlist exceptions - any technical name should be wrapped up in "`"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, whatever the right way to do this

https
init
inputId
Expand Down
11 changes: 10 additions & 1 deletion man/tm_g_gh_spaghettiplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.