-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Teal refactor #598
Teal refactor #598
Conversation
* Implement quosure and data to the module Co-authored-by: Mahmoud Hallal <mahmoud.hallal@roche.com> Co-authored-by: Maciej Nasinski <nasinski.maciej@gmail.com> Co-authored-by: Nikolas Burkoff <nikolas.burkoff@roche.com>
mapply(expression = res, id = paste(names(res), "call", sep = "_"), plot_stack_push) | ||
teal.code::chunks_push_chunks(plot_stack) | ||
teal.code::chunks_safe_eval() | ||
all_code <- shiny::reactive({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to all_q
for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will rename all reactives returning qenv to have _q
suffix.
table_stack_push <- function(...) { | ||
teal.code::chunks_push(..., chunks = table_stack) | ||
} | ||
q1 <- mmrm_fit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why "1"? do we have q2
there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is repeated multiple times for other modules as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix all the qenv objects to qenv
, qenv1
, ... etc.
chunk$push( | ||
bquote({ | ||
attr(counts[[.(get_n_name(groupby_vars))]], "label") <- "Count" # for plot | ||
counts <- counts %>% | ||
dplyr::group_by_at(.(as.vector(groupby_vars))) %>% | ||
dplyr::slice(1) %>% | ||
dplyr::ungroup() %>% | ||
dplyr::select(.(as.vector(groupby_vars)), dplyr::starts_with("n_")) | ||
}), | ||
id = "add_label_n_group_by_call" | ||
quo3 <- teal.code::eval_code( | ||
quo2, | ||
as.expression( | ||
c( | ||
bquote(attr(counts[[.(get_n_name(groupby_vars))]], "label") <- "Count"), | ||
bquote( | ||
counts <- counts %>% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously it was bquote({... <\n> ...})
and you converted this into as.expression(c(buote(...), bquote(...)))
and yours is more complex. May I ask what was the motivation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to avoid the {
in the code. I'll change it to the
qenv1 <- eval_code()
qenv2 <- eval_code(qenv1)
@@ -583,7 +594,7 @@ srv_g_forest_rsp <- function(id, | |||
|
|||
do.call(what = "validate_standard_inputs", validate_args) | |||
|
|||
teal::validate_one_row_per_id(anl_m$data(), key = c("USUBJID", "STUDYID", input_paramcd)) | |||
teal::validate_one_row_per_id(q1[["ANL"]], key = c("USUBJID", "STUDYID", input_paramcd)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few lines above you did: anl <- q1[["ANL"]]
so feel free to use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT? would it be more convenient to do anl_merged_df <- reactive(anl_merged_q()[["ANL"]])
and then use that reactive clause throughout the server?
list(arm_var, paramcd, subgroup_var, strata_var) | ||
), | ||
modal_title = label | ||
verbatim_content = reactive(teal.code::get_code(output_q())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT? would it be more convenient to do q_code <- reactive(teal.code::get_code(output_q()))
and use it throughout the server?
I am looking for creating some kind of template for module that is easy to follow by module developers
merged <- list( | ||
anl_input_r = anl_merged_input, | ||
adsl_input_r = adsl_merged_input, | ||
anl_q_r = anl_merged_q | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this is yet another way of managing objects
please make it more consistent across modules
adsl_filtered <- datasets$get_data(parentname, filtered = TRUE) | ||
anl_filtered <- datasets$get_data(dataname, filtered = TRUE) | ||
adsl_filtered <- data[[parentname]]() | ||
anl_filtered <- data[[dataname]]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it correct to use data
variable here? In other modules you get filtered datasets from merged_q
variable
* fixes after changes in teal.code * Update R/tm_t_ancova.R Co-authored-by: Maciej Nasinski <nasinski.maciej@gmail.com>
Signed-off-by: Nikolas Burkoff <nikolas.burkoff@roche.com>
I'm taking over the issue to address all the comments - please contact me before if you are planning to commit. |
# Pull Request This one line ``` name = "add_label_n_group_by_call" ``` cause the module to crash: ``` example(tm_g_barchart_simple, package = 'teal.modules.clinical') shinyApp(app$ui, app$server) Error in teal.code::eval_code: unused argument (name = "add_label_n_group_by_call") ``` Removing it helps, but have a look to be sure. P.S. it is PR number 666 \m/ Signed-off-by: Marek Blazewicz <110387997+BLAZEWIM@users.noreply.github.com>
…eal.modules.clinical into teal_refactor@main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UAT passed - we addressed all functional issues.
@ruckip comments to be addressed here #667
Part of insightsengineering/teal#731
FYI @shajoezhu once this goes in SME will be able to test the refactor hasn't broken anything