1010# ' @inheritParams teal::module
1111# ' @inheritParams shared_params
1212# ' @param parent_dataname (`character(1)`) string specifying a parent dataset.
13- # ' If it exists in `datasets_selected` then an extra checkbox will be shown to
13+ # ' If it exists in `datanames` then an extra checkbox will be shown to
1414# ' allow users to not show variables in other datasets which exist in this `dataname`.
1515# ' This is typically used to remove `ADSL` columns in `CDISC` data.
1616# ' In non `CDISC` data this can be ignored. Defaults to `"ADSL"`.
17- # ' @param datasets_selected (`character`) vector of datasets which should be
18- # ' shown, in order. Names must correspond with datasets names.
19- # ' If vector of length zero (default) then all datasets are shown.
20- # ' Note: Only `data.frame` objects are compatible; using other types will cause an error.
17+ # ' @param datasets_selected (`character`) `r lifecycle::badge("deprecated")` vector of datasets to show, please
18+ # ' use the `datanames` argument.
2119# '
2220# ' @inherit shared_params return
2321# '
8179# ' @export
8280# '
8381tm_variable_browser <- function (label = " Variable Browser" ,
84- datasets_selected = character (0 ),
82+ datasets_selected = deprecated(),
83+ datanames = if (missing(datasets_selected )) " all" else datasets_selected ,
8584 parent_dataname = " ADSL" ,
8685 pre_output = NULL ,
8786 post_output = NULL ,
@@ -90,22 +89,37 @@ tm_variable_browser <- function(label = "Variable Browser",
9089
9190 # Start of assertions
9291 checkmate :: assert_string(label )
93- checkmate :: assert_character(datasets_selected )
92+ if (! missing(datasets_selected )) {
93+ lifecycle :: deprecate_soft(
94+ when = " 0.4.0" ,
95+ what = " tm_variable_browser(datasets_selected)" ,
96+ with = " tm_variable_browser(datanames)" ,
97+ details = c(
98+ " If both `datasets_selected` and `datanames` are set `datasets_selected` will be silently ignored." ,
99+ i = ' Use `tm_variable_browser(datanames = "all")` to keep the previous behavior and avoid this warning.'
100+ )
101+ )
102+ }
103+ checkmate :: assert_character(datanames , min.len = 0 , min.chars = 1 , null.ok = TRUE )
94104 checkmate :: assert_character(parent_dataname , min.len = 0 , max.len = 1 )
95105 checkmate :: assert_multi_class(pre_output , c(" shiny.tag" , " shiny.tag.list" , " html" ), null.ok = TRUE )
96106 checkmate :: assert_multi_class(post_output , c(" shiny.tag" , " shiny.tag.list" , " html" ), null.ok = TRUE )
97107 checkmate :: assert_class(ggplot2_args , " ggplot2_args" )
98108 # End of assertions
99109
100- datasets_selected <- unique(datasets_selected )
110+ datanames <- if (identical(datanames , " all" )) {
111+ " all"
112+ } else {
113+ union(datanames , parent_dataname )
114+ }
101115
102116 ans <- module(
103117 label ,
104118 server = srv_variable_browser ,
105119 ui = ui_variable_browser ,
106- datanames = " all " ,
120+ datanames = datanames ,
107121 server_args = list (
108- datasets_selected = datasets_selected ,
122+ datanames = datanames ,
109123 parent_dataname = parent_dataname ,
110124 ggplot2_args = ggplot2_args
111125 ),
@@ -194,7 +208,7 @@ srv_variable_browser <- function(id,
194208 data ,
195209 reporter ,
196210 filter_panel_api ,
197- datasets_selected , parent_dataname , ggplot2_args ) {
211+ datanames , parent_dataname , ggplot2_args ) {
198212 with_reporter <- ! missing(reporter ) && inherits(reporter , " Reporter" )
199213 with_filter <- ! missing(filter_panel_api ) && inherits(filter_panel_api , " FilterPanelAPI" )
200214 checkmate :: assert_class(data , " reactive" )
@@ -212,18 +226,10 @@ srv_variable_browser <- function(id,
212226
213227 varname_numeric_as_factor <- reactiveValues()
214228
215- datanames <- isolate(names(data()))
216229 datanames <- Filter(function (name ) {
217230 is.data.frame(isolate(data())[[name ]])
218231 }, datanames )
219232
220- checkmate :: assert_character(datasets_selected )
221- checkmate :: assert_subset(datasets_selected , datanames )
222- if (! identical(datasets_selected , character (0 ))) {
223- checkmate :: assert_subset(datasets_selected , datanames )
224- datanames <- datasets_selected
225- }
226-
227233 output $ ui_variable_browser <- renderUI({
228234 ns <- session $ ns
229235 do.call(
0 commit comments