Skip to content

Commit 394cbea

Browse files
committed
r cmd check
1 parent a556485 commit 394cbea

34 files changed

+626
-322
lines changed

DESCRIPTION

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ BugReports: https://github.com/insightsengineering/teal.transform/issues
2121
Depends:
2222
R (>= 3.6)
2323
Imports:
24+
bsicons,
2425
checkmate (>= 2.1.0),
2526
dplyr (>= 1.1.0),
2627
htmltools,
@@ -30,20 +31,25 @@ Imports:
3031
shiny (>= 1.6.0),
3132
shinyjs (>= 2.1.0),
3233
shinyvalidate (>= 0.1.3),
34+
shinyWidgets,
3335
stats,
3436
teal,
37+
teal.code,
3538
teal.data (>= 0.8.0),
3639
teal.logger (>= 0.4.0),
3740
teal.widgets (>= 0.5.0),
3841
tidyr (>= 1.0.0),
3942
tidyselect (>= 1.2.1),
40-
utils
43+
utils,
44+
yaml
4145
Suggests:
4246
bslib (>= 0.8.0),
4347
knitr (>= 1.42),
4448
rmarkdown (>= 2.23),
49+
rvest,
4550
roxy.shinylive (>= 1.0.0),
4651
testthat (>= 3.1.5),
52+
tibble,
4753
withr (>= 2.0.0)
4854
VignetteBuilder:
4955
knitr,

NAMESPACE

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Generated by roxygen2: do not edit by hand
22

3-
S3method(.is.delayed,default)
4-
S3method(.is.delayed,list)
5-
S3method(.is.delayed,pick)
3+
S3method(.is_delayed,default)
4+
S3method(.is_delayed,list)
5+
S3method(.is_delayed,pick)
66
S3method(.picker_icon,Date)
7-
S3method(.picker_icon,MultiAssayExperiment)
87
S3method(.picker_icon,POSIXct)
98
S3method(.picker_icon,POSIXlt)
109
S3method(.picker_icon,character)
@@ -21,7 +20,6 @@ S3method(data_extract_multiple_srv,reactive)
2120
S3method(data_extract_srv,FilteredData)
2221
S3method(data_extract_srv,list)
2322
S3method(determine,datasets)
24-
S3method(determine,mae_data)
2523
S3method(determine,values)
2624
S3method(determine,variables)
2725
S3method(filter_spec_internal,default)
@@ -77,7 +75,6 @@ export(datasets)
7775
export(filter_spec)
7876
export(first_choice)
7977
export(first_choices)
80-
export(format)
8178
export(format_data_extract)
8279
export(get_anl_relabel_call)
8380
export(get_dataset_prefixed_col_names)
@@ -90,12 +87,10 @@ export(is_single_dataset)
9087
export(last_choice)
9188
export(last_choices)
9289
export(list_extract_spec)
93-
export(mae_data)
9490
export(merge_datasets)
9591
export(merge_expression_module)
9692
export(merge_expression_srv)
9793
export(merge_srv)
98-
export(no_more_choices_than)
9994
export(no_selected_as_NULL)
10095
export(picks)
10196
export(picks_srv)
@@ -107,6 +102,7 @@ export(select_spec.default)
107102
export(select_spec.delayed_data)
108103
export(split_by_sep)
109104
export(teal_transform_filter)
105+
export(tm_merge)
110106
export(value_choices)
111107
export(values)
112108
export(variable_choices)

R/0-as_picks.R

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#' Convert data_extract_spec to picks
22
#'
33
#' Helper functions to ease transition between [data_extract_spec()] and [picks()].
4+
#' @inheritParams teal::teal_transform_module
45
#' @param x (`data_extract_spec`, `select_spec`, `filter_spec`) object to convert to [`picks`]
5-
#'
66
#' @details
77
#' With introduction of [`picks`], [`data_extract_spec`] will no longer serve a primary tool to
88
#' define variable choices and default selection in teal-modules and eventually [`data_extract_spec`]
@@ -51,18 +51,18 @@
5151
#' )
5252
#'
5353
#' @export
54-
as.picks <- function(x, ...) {
54+
as.picks <- function(x) { # nolint
5555
if (inherits(x, c("picks", "pick"))) {
5656
x
5757
} else if (checkmate::test_list(x, c("data_extract_spec", "filter_spec"))) {
58-
Filter(length, lapply(x, as.picks, ...))
58+
Filter(length, lapply(x, as.picks))
5959
} else if (inherits(x, "data_extract_spec")) {
6060
args <- Filter(
6161
length,
6262
list(
6363
datasets(choices = x$dataname, fixed = TRUE),
6464
as.picks(x$select),
65-
as.picks(x$filter, dataname = x$dataname)
65+
as.picks(x$filter)
6666
# filter_spec as they are not necessary linked with `select` (selected variables)
6767
# as filter_spec can be specified on the variable(s) different than select_spec for example:
6868
# for example: #pseudocode select = select_spec(AVAL); filter = filter_spec(PARAMCD))
@@ -72,7 +72,6 @@ as.picks <- function(x, ...) {
7272
} else if (inherits(x, "select_spec")) {
7373
.select_spec_to_variables(x)
7474
} else if (inherits(x, "filter_spec")) {
75-
dataname <- list(...)$dataname
7675
# warning
7776
warning(
7877
"`filter_spec` are not convertible to picks - please use `transformers` argument",
@@ -113,7 +112,7 @@ as.picks <- function(x, ...) {
113112
teal_transform_filter <- function(x, label = "Filter") {
114113
checkmate::assert_multi_class(x, c("data_extract_spec", "picks"))
115114
if (inherits(x, "data_extract_spec")) {
116-
lapply(as.picks.filter(x), teal_transform_filter, label = label)
115+
lapply(.as.picks.filter(x), teal_transform_filter, label = label)
117116
} else {
118117
checkmate::assert_true("values" %in% names(x))
119118
teal::teal_transform_module(
@@ -123,11 +122,10 @@ teal_transform_filter <- function(x, label = "Filter") {
123122
picks_ui(ns("transformer"), picks = x, container = div)
124123
},
125124
server <- function(id, data) {
126-
moduleServer(id, function(input, output, session) {
125+
shiny::moduleServer(id, function(input, output, session) {
127126
selector <- picks_srv("transformer", picks = x, data = data)
128127
reactive({
129128
req(data(), selector())
130-
# todo: make sure filter call is not executed when setequal(selected, all_possible_choices)
131129
filter_call <- .make_filter_call(
132130
datasets = selector()$datasets$selected,
133131
variables = selector()$variables$selected,
@@ -141,7 +139,7 @@ teal_transform_filter <- function(x, label = "Filter") {
141139
}
142140
}
143141

144-
as.picks.filter <- function(x, dataname) {
142+
.as.picks.filter <- function(x, dataname) { # nolint
145143
if (inherits(x, "filter_spec")) {
146144
if (inherits(x$choices, "delayed_data")) {
147145
warning(
@@ -163,12 +161,12 @@ as.picks.filter <- function(x, dataname) {
163161
values(choices = x$choices, selected = x$selected, multiple = x$multiple)
164162
)
165163
} else if (checkmate::test_list(x, "filter_spec")) {
166-
lapply(x, as.picks.filter, dataname = dataname)
164+
lapply(x, .as.picks.filter, dataname = dataname)
167165
} else if (inherits(x, "data_extract_spec")) {
168-
as.picks.filter(x$filter, dataname = x$dataname)
166+
.as.picks.filter(x$filter, dataname = x$dataname)
169167
} else if (checkmate::test_list(x, c("data_extract_spec", "list", "NULL"))) {
170168
unlist(
171-
lapply(Filter(length, x), as.picks.filter),
169+
lapply(Filter(length, x), .as.picks.filter),
172170
recursive = FALSE
173171
)
174172
}

R/0-badge_dropdown.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#' Dropdown badge
1+
#' Drop-down badge
22
#'
3-
#' Dropdown button in a form of a badge with `bg-primary` as default style
4-
#' Clicking badge shows a dropdown containing any `HTML` element. Folded dropdown
3+
#' Drop-down button in a form of a badge with `bg-primary` as default style
4+
#' Clicking badge shows a drop-down containing any `HTML` element. Folded drop-down
55
#' doesn't trigger display output which means that items rendered using `render*`
6-
#' will be recomputed only when dropdown is show.
6+
#' will be recomputed only when drop-down is show.
77
#'
88
#' @param id (`character(1)`) shiny module's id
99
#' @param label (`shiny.tag`) Label displayed on a badge.
10-
#' @param ... (`shiny.tag`) Content of a dropdown.
10+
#' @param content (`shiny.tag`) Content of a drop-down.
1111
#' @keywords internal
1212
badge_dropdown <- function(id, label, content) {
1313
ns <- shiny::NS(id)
@@ -28,7 +28,11 @@ badge_dropdown <- function(id, label, content) {
2828
htmltools::tags$div(
2929
content,
3030
id = ns("inputs_container"),
31-
style = "visibility: hidden; opacity: 0; pointer-events: none; position: absolute; background: white; border: 1px solid #ccc; border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); padding: 10px; z-index: 1000; min-width: 200px; transition: opacity 0.2s ease;",
31+
style = paste(
32+
"visibility: hidden; opacity: 0; pointer-events: none; position: absolute; background: white;",
33+
"border: 1px solid #ccc; border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,0.1);",
34+
"padding: 10px; z-index: 1000; min-width: 200px; transition: opacity 0.2s ease;"
35+
)
3236
)
3337
)
3438
)

R/0-call_utils.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ calls_combine_by <- function(operator, calls) {
241241
)
242242
}
243243

244-
.call_dplyr_filter <- function(A) {
245-
predicates <- lapply(unname(A), function(x) {
244+
.call_dplyr_filter <- function(x) {
245+
predicates <- lapply(unname(x), function(x) {
246246
if (is.numeric(x$values)) {
247247
call_condition_range(varname = x$variables, range = x$values)
248248
} else if (inherits(x$values, "Date")) {

R/0-mae-methods.R

Lines changed: 0 additions & 25 deletions
This file was deleted.

R/0-module_merge.R

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,15 @@
2727
#' Default is `"dplyr::inner_join"`. The function must accept `by` and `suffix` parameters.
2828
#'
2929
#' @return A `list` with two reactive elements:
30-
#' \describe{
31-
#' \item{`data`}{A `reactive` returning a [teal.data::teal_data] object containing the merged dataset.
30+
#' - `data`A `reactive` returning a [teal.data::teal_data] object containing the merged dataset.
3231
#' The merged dataset is named according to `output_name` parameter. The `teal_data` object includes:
3332
#' - The merged dataset with all selected variables
3433
#' - Complete R code to reproduce the merge operation
35-
#' - Updated join keys reflecting the merged dataset structure}
36-
#' \item{`variables`}{A `reactive` returning a named list mapping selector names to their selected
34+
#' - Updated join keys reflecting the merged dataset structure
35+
#' - `variables` A `reactive` returning a named list mapping selector names to their selected
3736
#' variables in the merged dataset. The structure is:
3837
#' `list(selector_name_1 = c("var1", "var2"), selector_name_2 = c("var3", "var4"), ...)`.
39-
#' Variable names reflect any renaming that occurred during the merge to avoid conflicts.}
40-
#' }
38+
#' Variable names reflect any renaming that occurred during the merge to avoid conflicts.
4139
#'
4240
#' @section How It Works:
4341
#'
@@ -63,7 +61,7 @@
6361
#' - Joins datasets using specified join function and join keys
6462
#' - Maintains reproducibility through generated R code
6563
#'
66-
#' 6. **Updates Join Keys**: Creates new join key relationships for the merged dataset ("anl")
64+
#' 6. **Updates Join Keys**: Creates new join key relationships for the merged dataset (`"anl"`)
6765
#' relative to remaining datasets in the `teal_data` object
6866
#'
6967
#' 7. **Tracks Variables**: Keeps track of the variable names in the merged dataset
@@ -142,7 +140,6 @@
142140
#' - [teal.data::join_keys()] for defining dataset relationships
143141
#'
144142
#' @examples
145-
#' \dontrun{
146143
#' # Complete example with CDISC data
147144
#' library(teal.transform)
148145
#' library(teal.data)
@@ -195,14 +192,11 @@
195192
#' merged$variables()
196193
#' })
197194
#' }
198-
#'
199-
#' shinyApp(ui, server)
195+
#' if (interactive()) {
196+
#' shinyApp(ui, server)
200197
#' }
201198
#'
202199
#' @export
203-
# todo: merge_ui to display error message somewhere (at least)
204-
# - if this dataset has no join_keys to anl (anl_datasets) then error saying
205-
# can't merge {dataset} with merged dataset composed of {anl_datasets}
206200
merge_srv <- function(id,
207201
data,
208202
selectors,
@@ -298,14 +292,13 @@ merge_srv <- function(id,
298292
this_variables <- this_variables[!duplicated(unname(this_variables))] # because unique drops names
299293

300294
this_call <- .call_dplyr_select(dataname = dataname, variables = this_variables)
301-
# todo: make sure filter call is not executed when setequal(selected, all_possible_choices)
302295
this_call <- calls_combine_by("%>%", c(this_call, .call_dplyr_filter(this_filter_mapping)))
303296

304297
if (i > 1) {
305298
anl_vs_this <- setdiff(anl_primary_keys, this_primary_keys)
306299
this_vs_anl <- setdiff(this_primary_keys, anl_primary_keys)
307300
if (length(anl_vs_this) && length(this_vs_anl)) {
308-
# validate(need(FALSE, "cartesian join")) # todo: add more info
301+
warning("cartesian join - happens when primary keys A is not a subset of B and B is not a subset of A")
309302
}
310303
this_call <- as.call(
311304
list(
@@ -489,7 +482,7 @@ merge_srv <- function(id,
489482
need(
490483
FALSE,
491484
sprintf(
492-
"Cannot merge datasets. The following dataset%s no join keys defined: %s.\n\nPlease define join keys using teal.data::join_keys().",
485+
"Cannot merge datasets. The following dataset%s no join keys defined: %s.\n\nPlease define `join_keys`.",
493486
if (length(datasets_without_keys) == 1) " has" else "s have",
494487
paste(sprintf("'%s'", datasets_without_keys), collapse = ", ")
495488
)
@@ -517,7 +510,10 @@ merge_srv <- function(id,
517510
need(
518511
FALSE,
519512
sprintf(
520-
"Cannot merge dataset '%s'. No join keys found between '%s' and any of the accumulated datasets: %s.\n\nPlease define join keys using teal.data::join_keys().",
513+
paste(
514+
"Cannot merge dataset '%s'. No join keys found between '%s' and any of the accumulated datasets:",
515+
"%s.\n\nPlease define join keys using teal.data::join_keys()."
516+
),
521517
current_dataset,
522518
current_dataset,
523519
paste(sprintf("'%s'", accumulated), collapse = ", ")
@@ -535,7 +531,7 @@ merge_srv <- function(id,
535531

536532
.validate_is_eager <- function(x) {
537533
validate(need(
538-
!.is.delayed(x),
534+
!.is_delayed(x),
539535
"selected values have not been resolved correctly. Please report this issue to an app-developer."
540536
))
541537
}

0 commit comments

Comments
 (0)