Skip to content
Open

picks #270

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
e0e1571
Add some initial definitions
llrs-roche Mar 3, 2025
707224e
Add some infrastructure
llrs-roche Mar 3, 2025
9f9aacb
Resolution tested up to variables
llrs-roche Mar 5, 2025
0d89dce
Add function for when a new selection is chosen
llrs-roche Mar 6, 2025
58182d2
Raising more errors and silencing some tests
llrs-roche Mar 7, 2025
c21591f
Improve update_spec
llrs-roche Mar 10, 2025
8023b1c
Simplify tests
llrs-roche Mar 10, 2025
37225be
Add print method
llrs-roche Mar 10, 2025
e1ec420
Uncomment some tests
llrs-roche Mar 10, 2025
a8bb226
Make print work
llrs-roche Mar 10, 2025
f4bf89a
Move delayed to attributes
llrs-roche Mar 12, 2025
a1678fa
Add missing method!
llrs-roche Mar 12, 2025
06c0eb9
Simplify type creation
llrs-roche Mar 12, 2025
208fb53
Simplify resolver
llrs-roche Mar 12, 2025
cb94d6d
Delayed takes into consideration the selection too
llrs-roche Mar 12, 2025
158eda9
Fix mistake and remove delayed class
llrs-roche Mar 12, 2025
d545331
Resolve better by names
llrs-roche Mar 12, 2025
99cadc2
Fix issues
llrs-roche Mar 12, 2025
b26695a
Simplify c.type
llrs-roche Mar 12, 2025
6600d17
Use Group Generic Functions
llrs-roche Mar 12, 2025
df47b48
Improve tests
llrs-roche Mar 12, 2025
e90025c
Make it work for simple cases of values
llrs-roche Mar 12, 2025
a92f051
Allow OR combinations
llrs-roche Mar 13, 2025
41800f3
Make it easier to work with types
llrs-roche Mar 17, 2025
3a39de2
Avoid conflicting names
llrs-roche Mar 17, 2025
6920d6e
Simplify according to new methods
llrs-roche Mar 17, 2025
d728739
Updating docs
llrs-roche Mar 17, 2025
6a85027
Fix some checks
llrs-roche Mar 17, 2025
9993468
Simplify and reorganize delayed
llrs-roche Mar 18, 2025
3624441
Basic operations work more flexible
llrs-roche Mar 19, 2025
941b172
Simplify code
llrs-roche Mar 25, 2025
fe138e9
Add more checks
llrs-roche Mar 25, 2025
cf2d634
Resolve only what is possible.
llrs-roche Mar 25, 2025
3385521
Combine safely multiple types
llrs-roche Mar 25, 2025
2c42af5
Add documentation for types
llrs-roche Mar 25, 2025
3cd9132
Better handling of types not resolved
llrs-roche Mar 25, 2025
b780107
Better handling of resolver
llrs-roche Mar 25, 2025
9cfb6f8
Better handling of composing
llrs-roche Mar 25, 2025
bad225d
Adding some other files
llrs-roche Mar 25, 2025
c4c8e40
Add update_spec
llrs-roche Mar 25, 2025
635ea9b
Module for simple specifications
llrs-roche Mar 25, 2025
a30ec58
Update for multiple selections
llrs-roche Mar 26, 2025
3031edc
Make sure a list of transformators work
llrs-roche Mar 26, 2025
81c3a9b
Allow lists (should be of transforms)
llrs-roche Mar 31, 2025
d7a005b
Remove some comments
llrs-roche Mar 31, 2025
fa89e05
Merging basic block
llrs-roche Mar 31, 2025
0142b78
[skip style] [skip vbump] Restyle files
github-actions[bot] Mar 31, 2025
521fd09
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Mar 31, 2025
54058d3
Rename to make it easier to read
llrs-roche Apr 2, 2025
957e59d
Minor tweaks
llrs-roche Apr 2, 2025
b440e3f
Merging for multiple data.frames
llrs-roche Apr 2, 2025
516c434
Add back the extract methods
llrs-roche Apr 2, 2025
e82f500
Add Method and the default (to be able to expand)
llrs-roche Apr 2, 2025
d4d826e
Extract multiple columns
llrs-roche Apr 4, 2025
56fa808
Improve naming and fix some bugs
llrs-roche Apr 4, 2025
bcbf304
Handle bare types
llrs-roche Apr 4, 2025
dabf731
Add some checks on the input
llrs-roche Apr 4, 2025
78a8e1f
Merging features
llrs-roche Apr 4, 2025
1426b06
Merge commit '521fd09460dc4eb57f21bd5b022cee59f311804a'
llrs-roche Apr 4, 2025
ee357b0
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 4, 2025
b266116
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Apr 4, 2025
8a2fcb6
Instead of a list make us of ...
llrs-roche Apr 7, 2025
b03e0d9
Solve most issues
llrs-roche Apr 7, 2025
7f14c03
Resolve conflicts
llrs-roche Apr 7, 2025
a19ed31
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 7, 2025
f146b4f
Fix some error/warnings
llrs-roche Apr 8, 2025
58fcf91
Apply styler
llrs-roche Apr 8, 2025
730aaa3
Merge branch 'redesign_extraction@main' of https://github.com/insight…
llrs-roche Apr 8, 2025
6aedd0a
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Apr 8, 2025
4807d7d
Add additional checks and case handling
llrs-roche Apr 9, 2025
33a18fc
Merge branch 'redesign_extraction@main' of https://github.com/insight…
llrs-roche Apr 9, 2025
711f92d
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Apr 9, 2025
06c4b07
Comment code related to MAE
llrs-roche Apr 9, 2025
8145d93
Merge branch 'redesign_extraction@main' of https://github.com/insight…
llrs-roche Apr 9, 2025
0d032cd
Minor improvements
llrs-roche Apr 9, 2025
c7f2675
Merge from a list of inputs
llrs-roche Apr 9, 2025
b733b34
Make it possible to consolidate input and extraction
llrs-roche Apr 10, 2025
1134bbd
Increase version
llrs-roche Apr 10, 2025
cc26a25
Merge data.frames within qenv
llrs-roche Apr 24, 2025
1c2ddad
WIP: add ! operator
llrs-roche Apr 24, 2025
4605b89
Merge branch 'main' into redesign_extraction@main
llrs-roche Apr 24, 2025
d27750f
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 24, 2025
810ce49
Address some checks warnings
llrs-roche Apr 24, 2025
8cea674
WIP: Add tests for ! operator
llrs-roche Apr 24, 2025
cf4c5b2
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 24, 2025
4a3c2c8
Use unique datasets before merging
llrs-roche Apr 25, 2025
59c6aff
Use consolidate_extraction to make sure merging is needed
llrs-roche Apr 25, 2025
11932a8
Verify it works without problems with just c()
llrs-roche Apr 25, 2025
7b306fc
[skip style] [skip vbump] Restyle files
github-actions[bot] Apr 25, 2025
bec03ff
Remove operators (and exclude)
llrs-roche Apr 28, 2025
3c32eab
Simplify
llrs-roche Apr 29, 2025
386232d
Add tidyselect::eval_select
llrs-roche Apr 29, 2025
64c42e2
Add support for expressions in types
llrs-roche Apr 30, 2025
2a00dd2
Use the tidyselect approach (remove operators)
llrs-roche Apr 30, 2025
a78ecce
Remove extra MAE methods
llrs-roche Apr 30, 2025
6fa687e
Fix issues
llrs-roche May 6, 2025
18df6fc
Fix remaining tests
llrs-roche May 6, 2025
5cadc43
Fix bugs
llrs-roche May 6, 2025
72c975f
Merge branch 'redesign_extraction@main' of https://github.com/insight…
llrs-roche May 6, 2025
50576d6
Add method for colData and avoid Infinite recursion
llrs-roche May 6, 2025
a031ad9
If selection is empty it stops
llrs-roche May 8, 2025
1535244
Rename x argument to names and transform class to specification
llrs-roche May 9, 2025
1385c1f
Revert testing to allow empty selection
llrs-roche May 9, 2025
85787b8
Fix problems with renamings
llrs-roche May 9, 2025
3fafc92
Extract before tidyselect on names
llrs-roche May 9, 2025
5ccfe34
Reuse extraction
llrs-roche May 9, 2025
10509da
Match expectations based on names
llrs-roche May 9, 2025
5b8b51d
Clean up of unused functions and arguments
llrs-roche May 9, 2025
29c6500
Restore test
llrs-roche May 9, 2025
3ba1bf5
Renaming
llrs-roche May 9, 2025
ced9053
Fix renaming issues
llrs-roche May 12, 2025
f3e3fa3
Remove unused package
llrs-roche May 12, 2025
55a8537
Renaming
llrs-roche May 12, 2025
6bf1af3
Select instead of merging
llrs-roche May 12, 2025
744a271
Add function to provide the list of inputs
llrs-roche May 12, 2025
c773304
Improve calls and merging
llrs-roche May 13, 2025
0638534
Fix unresolved updates
llrs-roche May 14, 2025
ce36549
Merge remote-tracking branch 'origin/main' into redesign_extraction@main
gogonzo Jul 21, 2025
a1fc90b
checkpoint
gogonzo Jul 29, 2025
712781e
Merge remote-tracking branch 'origin/main' into redesign_extraction@main
gogonzo Aug 20, 2025
a3014a9
WIP merge, 1st POC
gogonzo Aug 25, 2025
1ba7cd3
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Aug 25, 2025
8342b1e
- selectInput to pickerInput
gogonzo Aug 26, 2025
afb59bc
adding selector helpers
gogonzo Aug 27, 2025
d209b13
`spec` to `picks`
gogonzo Aug 29, 2025
61038cd
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Aug 29, 2025
abd4b97
WIP
gogonzo Sep 5, 2025
8794289
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Sep 5, 2025
dfbef1f
.determine_ to return vectors instead of type
gogonzo Sep 5, 2025
a97a193
"disable" filtered choices
gogonzo Sep 8, 2025
3ec348b
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Sep 8, 2025
7044c69
push needed for POC for MDR
gogonzo Sep 9, 2025
4d91478
fix double precision difference between input (R>js>R conversion) and R
gogonzo Sep 12, 2025
d1406e1
choices/selected reactive to data
gogonzo Sep 12, 2025
677d0cc
sealing up reactive mechanism
gogonzo Sep 15, 2025
5815d26
fix bug when numeric range is change outside of the transformer (eg f…
gogonzo Sep 17, 2025
e4e2b36
minor errors
gogonzo Sep 23, 2025
8b33a34
WIP
gogonzo Sep 23, 2025
db9d038
POC1
gogonzo Sep 24, 2025
905c787
don't trigger when changing selection
gogonzo Sep 24, 2025
5bde18e
value(selected = everything) by default
gogonzo Sep 24, 2025
67493a7
implement keep_order
gogonzo Sep 26, 2025
764333d
allow-empty
gogonzo Oct 1, 2025
1307329
- adding icons to pickerInput-choicesOpt
gogonzo Oct 7, 2025
e6c39df
WIP cleanup
gogonzo Oct 21, 2025
3302ffb
WIP cleanup
gogonzo Oct 24, 2025
c3f8e42
WIP
gogonzo Oct 29, 2025
a556485
[skip style] [skip vbump] Restyle files
github-actions[bot] Oct 30, 2025
394cbea
r cmd check
gogonzo Oct 30, 2025
566a18c
remove refactor notes
gogonzo Oct 30, 2025
621603d
pkgdown
gogonzo Oct 31, 2025
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
11 changes: 9 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ BugReports: https://github.com/insightsengineering/teal.transform/issues
Depends:
R (>= 3.6)
Imports:
bsicons,
checkmate (>= 2.1.0),
dplyr (>= 1.1.0),
htmltools,
Expand All @@ -30,19 +31,25 @@ Imports:
shiny (>= 1.6.0),
shinyjs (>= 2.1.0),
shinyvalidate (>= 0.1.3),
shinyWidgets,
stats,
teal,
teal.code,
teal.data (>= 0.8.0),
teal.logger (>= 0.4.0),
teal.widgets (>= 0.5.0),
tidyr (>= 1.0.0),
tidyselect (>= 1.2.1),
utils
utils,
yaml
Suggests:
bslib (>= 0.8.0),
knitr (>= 1.42),
rmarkdown (>= 2.23),
rvest,
roxy.shinylive (>= 1.0.0),
testthat (>= 3.1.5),
tibble,
withr (>= 2.0.0)
VignetteBuilder:
knitr,
Expand All @@ -58,4 +65,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
37 changes: 37 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
# Generated by roxygen2: do not edit by hand

S3method(.is_delayed,default)
S3method(.is_delayed,list)
S3method(.is_delayed,pick)
S3method(.picker_icon,Date)
S3method(.picker_icon,POSIXct)
S3method(.picker_icon,POSIXlt)
S3method(.picker_icon,character)
S3method(.picker_icon,data.frame)
S3method(.picker_icon,default)
S3method(.picker_icon,factor)
S3method(.picker_icon,integer)
S3method(.picker_icon,logical)
S3method(.picker_icon,numeric)
S3method(.picker_icon,primary_key)
S3method(data_extract_multiple_srv,FilteredData)
S3method(data_extract_multiple_srv,list)
S3method(data_extract_multiple_srv,reactive)
S3method(data_extract_srv,FilteredData)
S3method(data_extract_srv,list)
S3method(determine,datasets)
S3method(determine,values)
S3method(determine,variables)
S3method(filter_spec_internal,default)
S3method(filter_spec_internal,delayed_data)
S3method(format,pick)
S3method(format,picks)
S3method(merge_expression_module,list)
S3method(merge_expression_module,reactive)
S3method(merge_expression_srv,list)
S3method(merge_expression_srv,reactive)
S3method(picks_srv,list)
S3method(picks_srv,picks)
S3method(picks_ui,list)
S3method(picks_ui,picks)
S3method(print,choices_labeled)
S3method(print,delayed_choices_selected)
S3method(print,delayed_data_extract_spec)
Expand All @@ -19,6 +42,8 @@ S3method(print,delayed_select_spec)
S3method(print,delayed_value_choices)
S3method(print,delayed_variable_choices)
S3method(print,filter_spec)
S3method(print,pick)
S3method(print,picks)
S3method(resolve,default)
S3method(resolve,delayed_choices_selected)
S3method(resolve,delayed_data_extract_spec)
Expand All @@ -36,6 +61,7 @@ S3method(variable_choices,data.frame)
export("%>%")
export(add_no_selected_choices)
export(all_choices)
export(as.picks)
export(check_no_multiple_selection)
export(choices_labeled)
export(choices_selected)
Expand All @@ -45,6 +71,7 @@ export(data_extract_spec)
export(data_extract_srv)
export(data_extract_ui)
export(datanames_input)
export(datasets)
export(filter_spec)
export(first_choice)
export(first_choices)
Expand All @@ -55,20 +82,30 @@ export(get_extract_datanames)
export(get_merge_call)
export(get_relabel_call)
export(is.choices_selected)
export(is_categorical)
export(is_single_dataset)
export(last_choice)
export(last_choices)
export(list_extract_spec)
export(merge_datasets)
export(merge_expression_module)
export(merge_expression_srv)
export(merge_srv)
export(no_selected_as_NULL)
export(picks)
export(picks_srv)
export(picks_ui)
export(resolve_delayed)
export(resolver)
export(select_spec)
export(select_spec.default)
export(select_spec.delayed_data)
export(split_by_sep)
export(teal_transform_filter)
export(tm_merge)
export(value_choices)
export(values)
export(variable_choices)
export(variables)
import(shiny)
importFrom(dplyr,"%>%")
235 changes: 235 additions & 0 deletions R/0-as_picks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
#' Convert data_extract_spec to picks
#'
#' @description
#' `r lifecycle::badge("experimental")`
#' Helper functions to ease transition between [data_extract_spec()] and [picks()].
#' @inheritParams teal::teal_transform_module
#' @param x (`data_extract_spec`, `select_spec`, `filter_spec`) object to convert to [`picks`]
#' @details
#' With introduction of [`picks`], [`data_extract_spec`] will no longer serve a primary tool to
#' define variable choices and default selection in teal-modules and eventually [`data_extract_spec`]
#' will be deprecated.
#' To ease the transition to the new tool, we provide `as.picks` method which can handle 1:1
#' conversion from [`data_extract_spec`] to [`picks`]. Unfortunately, when [`data_extract_spec`]
#' contains [`filter_spec`] then `as.picks` is unable to provide reliable [`picks`] equivalent.
#'
#' @examples
#' # convert des with eager select_spec
#' as.picks(
#' data_extract_spec(
#' dataname = "iris",
#' select_spec(
#' choices = c("Sepal.Length", "Sepal.Width", "Species"),
#' selected = c("Sepal.Length", "Species"),
#' multiple = TRUE,
#' ordered = TRUE
#' )
#' )
#' )
#'
#' # convert des with delayed select_spec
#' as.picks(
#' data_extract_spec(
#' dataname = "iris",
#' select_spec(
#' choices = variable_choices("iris"),
#' selected = first_choice(),
#' multiple = TRUE,
#' ordered = TRUE
#' )
#' )
#' )
#'
#' as.picks(
#' data_extract_spec(
#' dataname = "iris",
#' select_spec(
#' choices = variable_choices("iris", subset = function(data) names(Filter(is.numeric, data))),
#' selected = first_choice(),
#' multiple = TRUE,
#' ordered = TRUE
#' )
#' )
#' )
#'
#' @export
as.picks <- function(x) { # nolint
if (inherits(x, c("picks", "pick"))) {
x
} else if (checkmate::test_list(x, c("data_extract_spec", "filter_spec"))) {
Filter(length, lapply(x, as.picks))
} else if (inherits(x, "data_extract_spec")) {
args <- Filter(
length,
list(
datasets(choices = x$dataname, fixed = TRUE),
as.picks(x$select),
as.picks(x$filter)
# filter_spec as they are not necessary linked with `select` (selected variables)
# as filter_spec can be specified on the variable(s) different than select_spec for example:
# for example: #pseudocode select = select_spec(AVAL); filter = filter_spec(PARAMCD))
)
)
do.call(picks, args)
} else if (inherits(x, "select_spec")) {
.select_spec_to_variables(x)
} else if (inherits(x, "filter_spec")) {
# warning
warning(
"`filter_spec` are not convertible to picks - please use `transformers` argument",
"and create `teal_transform_module` containing necessary filter. See `?teal_transform_filter`"
)

NULL
}
}

#' @rdname as.picks
#' @examples
#' # teal_transform_module build on teal.transform
#'
#' teal_transform_filter(
#' data_extract_spec(
#' dataname = "iris",
#' filter = filter_spec(
#' vars = "Species",
#' choices = c("setosa", "versicolor", "virginica"),
#' selected = c("setosa", "versicolor")
#' )
#' )
#' )
#'
#' teal_transform_filter(
#' picks(
#' datasets(choices = "iris", select = "iris"),
#' variables(choices = "Species", "Species"),
#' values(
#' choices = c("setosa", "versicolor", "virginica"),
#' selected = c("setosa", "versicolor")
#' )
#' )
#' )
#'
#' @export
teal_transform_filter <- function(x, label = "Filter") {
checkmate::assert_multi_class(x, c("data_extract_spec", "picks"))
if (inherits(x, "data_extract_spec")) {
lapply(.as.picks.filter(x), teal_transform_filter, label = label)
} else {
checkmate::assert_true("values" %in% names(x))
teal::teal_transform_module(
label = label,
ui <- function(id) {
ns <- NS(id)
picks_ui(ns("transformer"), picks = x, container = div)
},
server <- function(id, data) {
shiny::moduleServer(id, function(input, output, session) {
selector <- picks_srv("transformer", picks = x, data = data)
reactive({
req(data(), selector())
filter_call <- .make_filter_call(
datasets = selector()$datasets$selected,
variables = selector()$variables$selected,
values = selector()$values$selected
)
teal.code::eval_code(data(), filter_call)
})
})
}
)
}
}

.as.picks.filter <- function(x, dataname) { # nolint
if (inherits(x, "filter_spec")) {
if (inherits(x$choices, "delayed_data")) {
warning(
"filter_spec(choices) doesn't support delayed_data when using with teal_transform_filter. ",
"Setting to all possible choices..."
)
x$choices <- function(x) TRUE
}
if (inherits(x$selected, "delayed_data")) {
warning(
"filter_spec(selected) doesn't support delayed_data when using with teal_transform_filter. ",
"Setting to all possible choices..."
)
x$selected <- function(x) TRUE
}
picks(
datasets(choices = dataname, selected = dataname),
variables(choices = x$vars_choices, selected = x$vars_selected, multiple = FALSE), # can't be multiple
values(choices = x$choices, selected = x$selected, multiple = x$multiple)
)
} else if (checkmate::test_list(x, "filter_spec")) {
lapply(x, .as.picks.filter, dataname = dataname)
} else if (inherits(x, "data_extract_spec")) {
.as.picks.filter(x$filter, dataname = x$dataname)
} else if (checkmate::test_list(x, c("data_extract_spec", "list", "NULL"))) {
unlist(
lapply(Filter(length, x), .as.picks.filter),
recursive = FALSE
)
}
}

.make_filter_call <- function(datasets, variables, values) {
checkmate::assert_character(datasets)
checkmate::assert_character(variables)
checkmate::assert_character(values)
substitute(
dataname <- dplyr::filter(dataname, varname %in% values),
list(
dataname = as.name(datasets),
varname = if (length(variables) == 1) {
as.name(variables)
} else {
as.call(
c(
quote(paste),
lapply(variables, as.name),
list(sep = ", ")
)
)
},
values = values
)
)
}

.select_spec_to_variables <- function(x) {
if (length(x)) {
variables(
choices = if (inherits(x$choices, "delayed_data")) {
out <- x$choices$subset
if (is.null(out)) {
function(x) TRUE # same effect as tidyselect::everything
} else {
class(out) <- "des-delayed"
out
}
} else {
x$choices
},
selected = if (inherits(x$selected, "delayed_choices")) {
out <- x$selected
class(out) <- "des-delayed"
out
} else if (inherits(x$selected, "delayed_data")) {
out <- x$selected$subset
if (is.null(out)) {
1L
} else {
class(out) <- "des-delayed"
out
}
} else {
unname(x$selected)
},
ordered = x$ordered,
multiple = x$multiple,
fixed = x$fixed
)
}
}
Loading
Loading