Skip to content

Commit c3bcba1

Browse files
authored
Merge branch 'main' into 152_add_search_tmfileviewer@main
2 parents 619fc66 + 6311e52 commit c3bcba1

File tree

3 files changed

+44
-24
lines changed

3 files changed

+44
-24
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: teal.modules.general
33
Title: General Modules for 'teal' Applications
4-
Version: 0.4.1.9008
4+
Version: 0.4.1.9009
55
Date: 2025-07-10
66
Authors@R: c(
77
person("Dawid", "Kaledkowski", , "[email protected]", role = c("aut", "cre")),

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# teal.modules.general 0.4.1.9008
1+
# teal.modules.general 0.4.1.9009
22

33
# teal.modules.general 0.4.1
44

R/tm_outliers.R

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -438,16 +438,31 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
438438
}
439439
})
440440

441+
# Used to create outlier table and the dropdown with additional columns
442+
dataname_first <- isolate(names(data())[[1]])
443+
444+
data_obj <- reactive({
445+
obj <- data()
446+
if (length(teal.data::join_keys(obj)) == 0) {
447+
if (!".row_id" %in% names(obj[[dataname_first]])) {
448+
obj[[dataname_first]]$.row_id <- seq_len(nrow(obj[[dataname_first]]))
449+
}
450+
teal.data::join_keys(obj) <-
451+
teal.data::join_keys(teal.data::join_key(dataname_first, dataname_first, ".row_id"))
452+
}
453+
obj
454+
})
455+
441456
anl_merged_input <- teal.transform::merge_expression_srv(
442457
selector_list = reactive_select_input,
443-
datasets = data,
458+
datasets = data_obj,
444459
merge_function = "dplyr::inner_join"
445460
)
446461

447462
anl_merged_q <- reactive({
448463
req(anl_merged_input())
449464
teal.code::eval_code(
450-
data(),
465+
data_obj(),
451466
paste0(
452467
'library("dplyr");library("tidyr");', # nolint quotes
453468
'library("tibble");library("ggplot2");'
@@ -468,9 +483,6 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
468483
sum(is.na(ANL[[outlier_var]]))
469484
})
470485

471-
# Used to create outlier table and the dropdown with additional columns
472-
dataname_first <- isolate(names(data())[[1]])
473-
474486
common_code_q <- reactive({
475487
req(iv_r()$is_valid())
476488

@@ -616,25 +628,33 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
616628
)
617629

618630
# ANL_OUTLIER_EXTENDED is the base table
619-
qenv <- teal.code::eval_code(
620-
qenv,
621-
substitute(
622-
expr = {
623-
ANL_OUTLIER_EXTENDED <- dplyr::left_join(
624-
ANL_OUTLIER,
625-
dplyr::select(
626-
dataname,
627-
dplyr::setdiff(names(dataname), dplyr::setdiff(names(ANL_OUTLIER), join_keys))
628-
),
629-
by = join_keys
631+
join_keys <- as.character(teal.data::join_keys(data_obj())[dataname_first, dataname_first])
632+
633+
if (length(join_keys) == 1 && join_keys == ".row_id") {
634+
# Dummy join key - single dataset, no join needed
635+
qenv <- teal.code::eval_code(qenv, quote(ANL_OUTLIER_EXTENDED <- ANL_OUTLIER))
636+
} else {
637+
# Join keys exist - perform left join
638+
qenv <- teal.code::eval_code(
639+
qenv,
640+
substitute(
641+
expr = {
642+
ANL_OUTLIER_EXTENDED <- dplyr::left_join(
643+
ANL_OUTLIER,
644+
dplyr::select(
645+
dataname,
646+
dplyr::setdiff(names(dataname), dplyr::setdiff(names(ANL_OUTLIER), join_keys))
647+
),
648+
by = join_keys
649+
)
650+
},
651+
env = list(
652+
dataname = as.name(dataname_first),
653+
join_keys = join_keys
630654
)
631-
},
632-
env = list(
633-
dataname = as.name(dataname_first),
634-
join_keys = as.character(teal.data::join_keys(data())[dataname_first, dataname_first])
635655
)
636656
)
637-
)
657+
}
638658

639659
qenv <- if (length(categorical_var) > 0) {
640660
qenv <- teal.code::eval_code(
@@ -1150,7 +1170,7 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
11501170
brushing = TRUE
11511171
)
11521172

1153-
choices <- reactive(teal.transform::variable_choices(data()[[dataname_first]]))
1173+
choices <- reactive(teal.transform::variable_choices(data_obj()[[dataname_first]]))
11541174

11551175
observeEvent(common_code_q(), {
11561176
ANL_OUTLIER <- common_code_q()[["ANL_OUTLIER"]]

0 commit comments

Comments
 (0)