Skip to content

Commit 14a9021

Browse files
authored
[skip vbump] initial release v0.1.0 (#79)
Fix #51
1 parent 780e17a commit 14a9021

29 files changed

Lines changed: 201 additions & 26 deletions

DESCRIPTION

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@ Type: Package
22
Package: teal.picks
33
Title: Dataset and Variable Picker and Merge Module for 'teal'
44
Applications
5-
Version: 0.1.0.9244
6-
Date: 2026-05-08
7-
Authors@R:
8-
person("insightsengineering", , , "insightsengineering@example.com", role = c("aut", "cre"))
5+
Version: 0.1.0
6+
Date: 2026-05-07
7+
Authors@R: c(
8+
person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre"),
9+
comment = c(ORCID = "0000-0001-9533-457X")),
10+
person("Andre", "Verissimo", , "andre.verissimo@roche.com", role = "aut",
11+
comment = c(ORCID = "0000-0002-2212-339X")),
12+
person("Marcin", "Kosinski", , "marcin.kosinski.mk1@roche.com", role = "aut"),
13+
person("Lluís", "Revilla Sancho", , "lluis.revilla_sancho@roche.com", role = "aut",
14+
comment = c(ORCID = "0000-0001-9747-2570")),
15+
person("Oriol", "Senan", , "oriol.senan@external.roche.com", role = "aut",
16+
comment = c(ORCID = "0000-0002-9621-3371")),
17+
person("Dony", "Unardi", , "unardid@gene.com", role = "rev"),
18+
person("F. Hoffmann-La Roche AG", role = c("cph", "fnd"))
19+
)
920
Description: Allows users to interactively select datasets, variables, and
1021
values within 'teal' applications using a 'tidyselect'-style
1122
interface. Selected picks can be merged and transformed into

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# teal.picks 0.1.0.9244
1+
# teal.picks 0.1.0
22

33
### New Features
44

R/as_picks.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#' conversion from [`data_extract_spec`] to [`picks`]. Unfortunately, when [`data_extract_spec`]
1515
#' contains [`filter_spec`] then `as.picks` is unable to provide reliable [`picks`] equivalent.
1616
#'
17+
#' @return A `picks` object when conversion is possible, otherwise `NULL` with a warning (if `quiet = FALSE`).
1718
#' @examples
1819
#' # convert des with eager select_spec
1920
#' as.picks(

R/call_utils.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ calls_combine_by <- function(operator, calls) {
233233
#' @param variables (`list` of `character`) variables to select. If list is named then
234234
#' variables will be renamed if their name is different than its value
235235
#' (this produces a call `select(..., <name> = <value>)`).
236+
#' @return `call`.
236237
#' @keywords internal
237238
.call_dplyr_select <- function(dataname, variables) {
238239
as.call(
@@ -250,6 +251,7 @@ calls_combine_by <- function(operator, calls) {
250251
#'
251252
#' Create a `dplyr::filter` call
252253
#' @param x (`list`) containing `variables` and `values`
254+
#' @return `call`.
253255
#' @keywords internal
254256
.call_dplyr_filter <- function(x) {
255257
if (any(!names(x) %in% c("variables", "values"))) {

R/interaction.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
#' `var2` in `vars`, or `NA` where a variable is not found.
1515
#'
1616
#' @export
17+
#' @examples
18+
#' picks(
19+
#' datasets("ADAE"),
20+
#' variables(
21+
#' c(AGE, RACE, interaction_vars("COUNTRY", "RACE")),
22+
#' selected = "COUNTRY:RACE",
23+
#' multiple = TRUE
24+
#' ),
25+
#' values()
26+
#' )
1727
interaction_vars <- function(var1, var2, vars = tidyselect::peek_vars(fn = "interaction_vars")) {
1828
new_var <- c(as.character(substitute(var1)), as.character(substitute(var2)))
1929
result <- match(new_var, vars)

R/module_merge.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ merge_srv <- function(id,
482482
#'
483483
#' @inheritParams merge_srv
484484
#' @param join_keys (`join_keys`) The join keys object
485+
#' @return `TRUE` if validation passes, otherwise raises a validation
486+
#' error with details on which datasets cannot be merged and why.
485487
#'
486488
#' @keywords internal
487489
.validate_join_keys <- function(selectors, join_keys) {

R/module_picks.R

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,35 @@
3232
#' @seealso [picks()] for creating `picks`` objects
3333
#'
3434
#' @name picks_module
35+
#' @examples
36+
#' library(shiny)
37+
#'
38+
#' example_pick <- picks(
39+
#' datasets("ADSL"),
40+
#' variables(selected = c("SEX", "COUNTRY", "ARMCD"))
41+
#' )
42+
#' ui <- fluidPage(
43+
#' picks_ui("my_picks", picks = example_pick),
44+
#' h4("Resolved picks:"),
45+
#' verbatimTextOutput("result"),
46+
#' h4("Table:"),
47+
#' tableOutput("table")
48+
#' )
49+
#' server <- function(input, output, session) {
50+
#' data <- teal.data::teal_data("ADSL" = teal.data::rADSL)
51+
#' teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys["ADSL"]
52+
#' selectors <- picks_srv(
53+
#' picks = list(my_picks = example_pick),
54+
#' data = reactive(data)
55+
#' )
56+
#' anl <- merge_srv("merge", data = reactive(data), selectors = selectors)
57+
#' output$result <- renderPrint(cat(gsub("\033\\[[0-9;]*m", "", format(selectors$my_picks()))))
58+
#' output$table <- renderTable(anl$data()$anl)
59+
#' }
60+
#'
61+
#' if (interactive()) {
62+
#' shinyApp(ui, server)
63+
#' }
3564
NULL
3665

3766
#' @rdname picks_module
@@ -327,6 +356,7 @@ picks_srv.picks <- function(id, picks, data) {
327356
.pick_ui_fixed <- function(id, selected) {
328357
htmltools::tags$div(
329358
class = "form-group shiny-input-container",
359+
style = "visibility: hidden; position: absolute;",
330360
htmltools::tags$input(
331361
id = id,
332362
disabled = "disabled",
@@ -396,6 +426,7 @@ picks_srv.picks <- function(id, picks, data) {
396426
#' @param rv (`reactiveVal`)
397427
#' @param value (`vector`)
398428
#' @param log (`character(1)`) message to `log_debug`
429+
#' @return the result of `reactiveVal` update if new value is different, `NULL` otherwise.
399430
#' @keywords internal
400431
.update_rv <- function(rv, value, log) {
401432
if (!isTRUE(all.equal(rv(), value, tolerance = 1e-15))) { # tolerance 1e-15 is a max precision in widgets.
@@ -420,6 +451,8 @@ picks_srv.picks <- function(id, picks, data) {
420451
#' @param picks_resolved (`reactiveVal`)
421452
#' @param old_picks (`picks`)
422453
#' @param data (`any` asserted further in `resolver`)
454+
#' @return The result of changing the `picks_resolved` `reactiveVal` given as argument.
455+
#' It returns `NULL` if it does nothing.
423456
#' @keywords internal
424457
.resolve <- function(selected, slot_name, picks_resolved, old_picks, data) {
425458
checkmate::assert_vector(selected, null.ok = TRUE)
@@ -479,7 +512,6 @@ picks_srv.picks <- function(id, picks, data) {
479512
#' Otherwise `default`.
480513
#'
481514
#' @keywords internal
482-
#'
483515
restoreValue <- function(value, default) { # nolint: object_name.
484516
checkmate::assert_character("value")
485517
session_default <- shiny::getDefaultReactiveDomain()

R/picks.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#' @param check_dataset (`logical(1)`) whether to check that the first element of `picks` is `datasets()`.
2121
#' This is useful to set to `FALSE` when creating picks objects that have a required dataset that is not
2222
#' selected by the user and defined in the module itself.
23+
#' @return For `picks()` it returns an object of `picks` class, which is a list of `pick` objects with additional
24+
#' attributes for Shiny interactivity.
25+
#' For `datasets()`, `variables()`, and `values()` it returns a `pick` object with
26+
#' class corresponding to the type of selection including the choices and selected values.
2327
#' @details
2428
#' # `tidyselect` support
2529
#'
@@ -377,6 +381,8 @@ values <- function(choices = function(x) !is.na(x),
377381
#'
378382
#' Create a `pick` object
379383
#' @inheritParams picks
384+
#' @return `pick` generic object that is used by [datasets()], [variables()] and [values()]
385+
#' to create objects of corresponding classes.
380386
#' @keywords internal
381387
.pick <- function(choices,
382388
selected,
@@ -390,7 +396,7 @@ values <- function(choices = function(x) !is.na(x),
390396
warning(
391397
warningCondition(
392398
paste0(
393-
deparse(sys.call(-1)),
399+
deparse1(sys.call(-1)),
394400
"\n - Setting explicit `selected` while `choices` are delayed (set using `tidyselect`) doesn't ",
395401
"guarantee that `selected` is a subset of `choices`."
396402
),
@@ -470,6 +476,9 @@ values <- function(choices = function(x) !is.na(x),
470476
#' - `function` when predicate function provided (delayed)
471477
#' - `atomic` when vector of choices/selected provided (eager)
472478
#' @param x (`list`, `list of picks`, `picks`, `pick`, `$choices`, `$selected`)
479+
#' @return A `logical(1)` indicating if any of the elements in picks is delayed.,
480+
#' For a single `pick`, such as [datasets()], [variables()] or [values()],
481+
#' it checks if either `choices` or `selected` are delayed.
473482
#' @keywords internal
474483
.is_delayed <- function(x) {
475484
UseMethod(".is_delayed")

R/tidyselect-helpers.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
#' @rdname tidyselectors
1212
#' @param min.len (`integer(1)`) minimal number of unique values
1313
#' @param max.len (`integer(1)`) maximal number of unique values
14+
#' @return A `tidyselector` that can be used directly in `choices` or `selected` of `variables()` in `picks()`.
1415
#' @export
1516
#' @examples
17+
#' # Supports tidyselect helpers, e.g. to select all categorical variables with 2 to 10 unique values
18+
#' dplyr::select(iris, dplyr::where(is_categorical(2, 10)))
19+
#'
1620
#' p <- picks(
1721
#' datasets(is.data.frame, 2L),
1822
#' variables(is_categorical(2, 10))
@@ -51,6 +55,8 @@ is_categorical <- function(min.len, max.len) {
5155
#' columns. An informative error is raised if the resolved column type is unsupported.
5256
#' @param min (`numeric(1)`) Minimal value.
5357
#' @param max (`numeric(1)`) Maximal value.
58+
#' @return A function that allows the use of a range in `choices` or `selected` of `values()` in
59+
#' `numeric`, `Date`, or `POSIXct` variables.
5460
#' @export
5561
#' @examples
5662
#' p <- picks(

R/tm_merge.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#'
55
#' @inheritParams teal::module
66
#' @param picks (`list` of `picks`)
7+
#' @return A `teal::module` object that merges datasets based on user selections and displays the results.
78
#' @examples
89
#' library(teal)
910
#'

0 commit comments

Comments
 (0)