diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e1cc7600e..646a00dbf2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,6 +37,9 @@ repos: - insightsengineering/teal.slice - insightsengineering/teal.widgets - utils + - shinytest2 # Necessary for documentation + - shinyvalidate # Necessary for documentation + - rvest # Necessary for documentation - id: spell-check name: Check spelling with `spelling` exclude: > diff --git a/DESCRIPTION b/DESCRIPTION index 8f33815491..daee6b551a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,7 +37,7 @@ BugReports: https://github.com/insightsengineering/teal/issues Depends: R (>= 4.0), shiny (>= 1.8.1), - teal.data (>= 0.6.0.9014), + teal.data (>= 0.6.0.9015), teal.slice (>= 0.5.1.9009) Imports: checkmate (>= 2.1.0), @@ -49,7 +49,7 @@ Imports: rlang (>= 1.0.0), shinyjs, stats, - teal.code (>= 0.5.0.9011), + teal.code (>= 0.5.0.9012), teal.logger (>= 0.2.0), teal.reporter (>= 0.3.1.9004), teal.widgets (>= 0.4.0), diff --git a/R/dummy_functions.R b/R/dummy_functions.R index fd3f067699..201ca6df8d 100644 --- a/R/dummy_functions.R +++ b/R/dummy_functions.R @@ -20,7 +20,7 @@ example_module <- function(label = "example teal module", datanames = "all", tra server = function(id, data) { checkmate::assert_class(isolate(data()), "teal_data") moduleServer(id, function(input, output, session) { - datanames_rv <- reactive(ls(teal.code::get_env((req(data()))))) + datanames_rv <- reactive(names(req(data()))) observeEvent(datanames_rv(), { selected <- input$dataname if (identical(selected, "")) { diff --git a/R/init.R b/R/init.R index 005bc448f9..a2c1fac786 100644 --- a/R/init.R +++ b/R/init.R @@ -207,16 +207,16 @@ init <- function(data, ## `data` - `modules` if (inherits(data, "teal_data")) { - if (length(ls(teal.code::get_env(data))) == 0) { + if (length(data) == 0) { stop("The environment of `data` is empty.") } - is_modules_ok <- check_modules_datanames(modules, ls(teal.code::get_env(data))) + is_modules_ok <- check_modules_datanames(modules, names(data)) if (!isTRUE(is_modules_ok) && length(unlist(extract_transformers(modules))) == 0) { warning(is_modules_ok, call. = FALSE) } - is_filter_ok <- check_filter_datanames(filter, ls(teal.code::get_env(data))) + is_filter_ok <- check_filter_datanames(filter, names(data)) if (!isTRUE(is_filter_ok)) { warning(is_filter_ok) # we allow app to continue if applied filters are outside diff --git a/R/module_data_summary.R b/R/module_data_summary.R index d97d4955e5..6fe96702b0 100644 --- a/R/module_data_summary.R +++ b/R/module_data_summary.R @@ -64,7 +64,7 @@ srv_data_summary <- function(id, teal_data) { summary_table <- reactive({ req(inherits(teal_data(), "teal_data")) - if (!length(ls(teal.code::get_env(teal_data())))) { + if (!length(teal_data())) { return(NULL) } get_filter_overview_wrapper(teal_data) @@ -142,7 +142,8 @@ srv_data_summary <- function(id, teal_data) { #' @rdname module_data_summary get_filter_overview_wrapper <- function(teal_data) { - datanames <- teal.data::datanames(teal_data()) + # Sort datanames in topological order + datanames <- names(teal_data()) joinkeys <- teal.data::join_keys(teal_data()) current_data_objs <- sapply( diff --git a/R/module_init_data.R b/R/module_init_data.R index 060d25afb5..4963587e94 100644 --- a/R/module_init_data.R +++ b/R/module_init_data.R @@ -101,7 +101,7 @@ srv_init_data <- function(id, data) { list(code = trimws(c(teal.code::get_code(data), hashes), which = "right")), list(join_keys = teal.data::join_keys(data)), sapply( - ls(teal.code::get_env(data)), + names(data), teal.code::get_var, object = data, simplify = FALSE @@ -121,7 +121,7 @@ srv_init_data <- function(id, data) { #' @return A character vector with the code lines. #' @keywords internal #' -.get_hashes_code <- function(data, datanames = ls(teal.code::get_env(data))) { +.get_hashes_code <- function(data, datanames = names(data)) { vapply( datanames, function(dataname, datasets) { diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index deb83cc59f..588227498a 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -364,11 +364,11 @@ srv_teal_module.teal_module <- function(id, .resolve_module_datanames <- function(data, modules) { stopifnot("data_rv must be teal_data object." = inherits(data, "teal_data")) if (is.null(modules$datanames) || identical(modules$datanames, "all")) { - .topologically_sort_datanames(ls(teal.code::get_env(data)), teal.data::join_keys(data)) + names(data) } else { intersect( - .include_parent_datanames(modules$datanames, teal.data::join_keys(data)), - ls(teal.code::get_env(data)) + names(data), # Keep topological order from teal.data::names() + .include_parent_datanames(modules$datanames, teal.data::join_keys(data)) ) } } diff --git a/R/module_teal.R b/R/module_teal.R index 3e913c2340..16d4ac280d 100644 --- a/R/module_teal.R +++ b/R/module_teal.R @@ -195,7 +195,7 @@ srv_teal <- function(id, data, modules, filter = teal_slices()) { ) data_rv <- reactive({ req(inherits(data_validated(), "teal_data")) - is_filter_ok <- check_filter_datanames(filter, ls(teal.code::get_env(data_validated()))) + is_filter_ok <- check_filter_datanames(filter, names(data_validated())) if (!isTRUE(is_filter_ok)) { showNotification( "Some filters were not applied because of incompatibility with data. Contact app developer.", diff --git a/R/module_teal_data.R b/R/module_teal_data.R index ebf95b115f..fbb8a64e9a 100644 --- a/R/module_teal_data.R +++ b/R/module_teal_data.R @@ -223,7 +223,7 @@ srv_check_shiny_warnings <- function(id, data, modules) { output$message <- renderUI({ if (inherits(data(), "teal_data")) { is_modules_ok <- check_modules_datanames_html( - modules = modules, datanames = ls(teal.code::get_env(data())) + modules = modules, datanames = names(data()) ) if (!isTRUE(is_modules_ok)) { tags$div(is_modules_ok, class = "teal-output-warning") diff --git a/R/teal_data_module.R b/R/teal_data_module.R index 99dec6bc01..ae1c815857 100644 --- a/R/teal_data_module.R +++ b/R/teal_data_module.R @@ -48,7 +48,6 @@ #' dataset2 <- mtcars #' } #' ) -#' datanames(data) <- c("dataset1", "dataset2") #' #' data #' }) diff --git a/R/teal_data_utils.R b/R/teal_data_utils.R index a92ee9cc05..f5244c5736 100644 --- a/R/teal_data_utils.R +++ b/R/teal_data_utils.R @@ -9,8 +9,8 @@ #' `teal.code` and `teal.data` methods. #' #' @param data (`teal_data`) -#' @param code (`character`) code to append to `data@code` -#' @param objects (`list`) objects to append to `data@env` +#' @param code (`character`) code to append to the object's code slot. +#' @param objects (`list`) objects to append to object's environment. #' @param datanames (`character`) names of the datasets #' @return modified `teal_data` #' @keywords internal @@ -33,8 +33,8 @@ NULL checkmate::assert_class(data, "teal_data") checkmate::assert_class(objects, "list") new_env <- list2env(objects, parent = .GlobalEnv) - rlang::env_coalesce(new_env, teal.code::get_env(data)) - data@env <- new_env + rlang::env_coalesce(new_env, as.environment(data)) + data@.xData <- new_env data } @@ -42,7 +42,7 @@ NULL .subset_teal_data <- function(data, datanames) { checkmate::assert_class(data, "teal_data") checkmate::assert_class(datanames, "character") - datanames_corrected <- intersect(datanames, ls(teal.code::get_env(data))) + datanames_corrected <- intersect(datanames, names(data)) datanames_corrected_with_raw <- c(datanames_corrected, ".raw_data") if (!length(datanames_corrected)) { return(teal_data()) @@ -51,7 +51,7 @@ NULL new_data <- do.call( teal.data::teal_data, args = c( - mget(x = datanames_corrected_with_raw, envir = teal.code::get_env(data)), + mget(x = datanames_corrected_with_raw, envir = as.environment(data)), list( code = teal.code::get_code(data, names = datanames_corrected_with_raw), join_keys = teal.data::join_keys(data)[datanames_corrected] @@ -59,6 +59,5 @@ NULL ) ) new_data@verified <- data@verified - teal.data::datanames(new_data) <- datanames_corrected new_data } diff --git a/R/utils.R b/R/utils.R index 312d3a5f73..6c3f8de083 100644 --- a/R/utils.R +++ b/R/utils.R @@ -46,24 +46,16 @@ get_teal_bs_theme <- function() { #' @keywords internal .include_parent_datanames <- function(datanames, join_keys) { ordered_datanames <- datanames - for (i in datanames) { - parents <- character(0) - while (length(i) > 0) { - parent_i <- teal.data::parent(join_keys, i) - parents <- c(parent_i, parents) - i <- parent_i + for (current in datanames) { + parents <- character(0L) + while (length(current) > 0) { + current <- teal.data::parent(join_keys, current) + parents <- c(current, parents) } ordered_datanames <- c(parents, ordered_datanames) } - unique(ordered_datanames) -} -#' Return topologicaly sorted datanames -#' @noRd -#' @keywords internal -.topologically_sort_datanames <- function(datanames, join_keys) { - datanames_with_parents <- .include_parent_datanames(datanames, join_keys) - intersect(datanames, datanames_with_parents) + unique(ordered_datanames) } #' Create a `FilteredData` @@ -71,18 +63,15 @@ get_teal_bs_theme <- function() { #' Create a `FilteredData` object from a `teal_data` object. #' #' @param x (`teal_data`) object -#' @param datanames (`character`) vector of data set names to include; must be subset of `datanames(x)` +#' @param datanames (`character`) vector of data set names to include; must be subset of `names(x)` #' @return A `FilteredData` object. #' @keywords internal -teal_data_to_filtered_data <- function(x, datanames = ls(teal.code::get_env(x))) { +teal_data_to_filtered_data <- function(x, datanames = names(x)) { checkmate::assert_class(x, "teal_data") checkmate::assert_character(datanames, min.chars = 1L, any.missing = FALSE) # Otherwise, FilteredData will be created in the modules' scope later teal.slice::init_filtered_data( - x = Filter( - length, - sapply(datanames, function(dn) x[[dn]], simplify = FALSE) - ), + x = Filter(length, sapply(datanames, function(dn) x[[dn]], simplify = FALSE)), join_keys = teal.data::join_keys(x) ) } @@ -328,7 +317,7 @@ create_app_id <- function(data, modules) { checkmate::assert_class(modules, "teal_modules") data <- if (inherits(data, "teal_data")) { - as.list(teal.code::get_env(data)) + as.list(data) } else if (inherits(data, "teal_data_module")) { deparse1(body(data$server)) } diff --git a/man/dot-get_hashes_code.Rd b/man/dot-get_hashes_code.Rd index 2b6d519312..5b16a6a56b 100644 --- a/man/dot-get_hashes_code.Rd +++ b/man/dot-get_hashes_code.Rd @@ -4,7 +4,7 @@ \alias{.get_hashes_code} \title{Get code that tests the integrity of the reproducible data} \usage{ -.get_hashes_code(data, datanames = ls(teal.code::get_env(data))) +.get_hashes_code(data, datanames = names(data)) } \arguments{ \item{data}{(\code{teal_data}) object holding the data} diff --git a/man/teal_data_module.Rd b/man/teal_data_module.Rd index a6034cca13..9c3cbd29f9 100644 --- a/man/teal_data_module.Rd +++ b/man/teal_data_module.Rd @@ -90,7 +90,6 @@ tdm <- teal_data_module( dataset2 <- mtcars } ) - datanames(data) <- c("dataset1", "dataset2") data }) diff --git a/man/teal_data_to_filtered_data.Rd b/man/teal_data_to_filtered_data.Rd index d6eecd90cd..2ba9162c73 100644 --- a/man/teal_data_to_filtered_data.Rd +++ b/man/teal_data_to_filtered_data.Rd @@ -4,12 +4,12 @@ \alias{teal_data_to_filtered_data} \title{Create a \code{FilteredData}} \usage{ -teal_data_to_filtered_data(x, datanames = ls(teal.code::get_env(x))) +teal_data_to_filtered_data(x, datanames = names(x)) } \arguments{ \item{x}{(\code{teal_data}) object} -\item{datanames}{(\code{character}) vector of data set names to include; must be subset of \code{datanames(x)}} +\item{datanames}{(\code{character}) vector of data set names to include; must be subset of \code{names(x)}} } \value{ A \code{FilteredData} object. diff --git a/man/teal_data_utilities.Rd b/man/teal_data_utilities.Rd index 07f850f124..f7943f3910 100644 --- a/man/teal_data_utilities.Rd +++ b/man/teal_data_utilities.Rd @@ -16,9 +16,9 @@ \arguments{ \item{data}{(\code{teal_data})} -\item{code}{(\code{character}) code to append to \code{data@code}} +\item{code}{(\code{character}) code to append to the object's code slot.} -\item{objects}{(\code{list}) objects to append to \code{data@env}} +\item{objects}{(\code{list}) objects to append to object's environment.} \item{datanames}{(\code{character}) names of the datasets} } diff --git a/tests/testthat/helper-shinytest2.R b/tests/testthat/helper-shinytest2.R index eca752fd73..0656e6db5f 100644 --- a/tests/testthat/helper-shinytest2.R +++ b/tests/testthat/helper-shinytest2.R @@ -3,7 +3,6 @@ simple_teal_data <- function() { iris <- iris mtcars <- mtcars }) - datanames(data) <- c("iris", "mtcars") data } @@ -17,7 +16,7 @@ report_module <- function(label = "example teal module") { reporter = reporter, card_fun = function(card) card ) - updateSelectInput(session, "dataname", choices = isolate(datanames(data()))) + updateSelectInput(session, "dataname", choices = isolate(names(data()))) output$dataset <- renderPrint({ req(input$dataname) data()[[input$dataname]] diff --git a/tests/testthat/test-module_teal.R b/tests/testthat/test-module_teal.R index 0ddf0e7717..dd60c2c619 100644 --- a/tests/testthat/test-module_teal.R +++ b/tests/testthat/test-module_teal.R @@ -483,9 +483,9 @@ testthat::describe("srv_teal teal_modules", { expr = { testthat::expect_null(modules_output$module_1()) session$setInputs(`data-teal_data_module-dataset` = "iris", `teal_modules-active_tab` = "module_1") - testthat::expect_setequal(ls(teal.code::get_env(modules_output$module_1()())), "iris") + testthat::expect_setequal(names(modules_output$module_1()()), "iris") session$setInputs(`data-teal_data_module-dataset` = "mtcars", `teal_modules-active_tab` = "module_2") - testthat::expect_setequal(ls(teal.code::get_env(modules_output$module_2()())), "mtcars") + testthat::expect_setequal(names(modules_output$module_2()()), "mtcars") } ) }) @@ -539,7 +539,7 @@ testthat::describe("srv_teal teal_modules", { ), expr = { session$setInputs(`teal_modules-active_tab` = "module_1") - testthat::expect_identical(teal.data::datanames(modules_output$module_1()()), "iris") + testthat::expect_identical(names(modules_output$module_1()()), "iris") testthat::expect_identical(modules_output$module_1()()[["iris"]], iris) } ) @@ -669,12 +669,12 @@ testthat::describe("srv_teal teal_modules", { ), expr = { session$setInputs(`teal_modules-active_tab` = "module_1") - testthat::expect_identical(teal.data::datanames(modules_output$module_1()()), "iris") + testthat::expect_identical(names(modules_output$module_1()()), "iris") } ) }) - testthat::it("receives all objects from @env when module$datanames = \"all\"", { + testthat::it("receives all objects from teal_data when module$datanames = \"all\"", { shiny::testServer( app = srv_teal, args = list( @@ -690,7 +690,7 @@ testthat::describe("srv_teal teal_modules", { expr = { session$setInputs(`teal_modules-active_tab` = "module_1") testthat::expect_identical( - teal.data::datanames(modules_output$module_1()()), + names(modules_output$module_1()()), c("iris", "iris_raw", "mtcars", "swiss") ) } @@ -754,7 +754,7 @@ testthat::describe("srv_teal teal_modules", { ), expr = { session$setInputs(`teal_modules-active_tab` = "module_1") - testthat::expect_identical(teal.data::datanames(modules_output$module_1()()), c("iris", "mtcars", "swiss")) + testthat::expect_identical(names(modules_output$module_1()()), c("iris", "mtcars", "swiss")) } ) }) @@ -791,7 +791,7 @@ testthat::describe("srv_teal teal_modules", { ), expr = { session$setInputs(`teal_modules-active_tab` = "module_1") - testthat::expect_identical(teal.data::datanames(modules_output$module_1()()), c("iris", "mtcars", "swiss")) + testthat::expect_identical(names(modules_output$module_1()()), c("iris", "mtcars", "swiss")) } ) }) @@ -819,7 +819,7 @@ testthat::describe("srv_teal teal_modules", { ), expr = { session$setInputs(`teal_modules-active_tab` = "module_1") - testthat::expect_setequal(ls(modules_output$module_1()()[[".raw_data"]]), c("iris", "swiss")) + testthat::expect_setequal(names(modules_output$module_1()()[[".raw_data"]]), c("iris", "swiss")) } ) }) @@ -852,7 +852,7 @@ testthat::describe("srv_teal teal_modules", { ), expr = { session$setInputs(`teal_modules-active_tab` = "module_1") - testthat::expect_identical(teal.data::datanames(modules_output$module_1()()), c("iris", "mtcars", "swiss")) + testthat::expect_identical(names(modules_output$module_1()()), c("iris", "mtcars", "swiss")) } ) }) @@ -890,7 +890,7 @@ testthat::describe("srv_teal teal_modules", { ), expr = { session$setInputs(`teal_modules-active_tab` = "module_1") - testthat::expect_identical(teal.data::datanames(modules_output$module_1()()), c("iris", "mtcars")) + testthat::expect_identical(names(modules_output$module_1()()), c("iris", "mtcars")) } ) }) @@ -2159,7 +2159,10 @@ testthat::describe("srv_teal summary table", { }) testthat::it("displays parent before child when join_keys are provided", { - data <- teal.data::teal_data(parent = mtcars, child = data.frame(am = c(0, 1), test = c("a", "b"))) + data <- teal.data::teal_data( + parent = mtcars, + child = data.frame(am = c(0, 1), test = c("a", "b")) + ) teal.data::join_keys(data) <- teal.data::join_keys( teal.data::join_key("parent", "child", keys = c("am")) @@ -2390,11 +2393,8 @@ testthat::describe("Datanames with special symbols", { session$flushReact() testthat::expect_setequal( - ls( - teal.code::get_env(modules_output$module_1()()), - all.names = TRUE - ), - c(".raw_data", "iris", "%a_pipe%") + names(modules_output$module_1()()), + c("iris", "%a_pipe%") ) } ) @@ -2421,12 +2421,10 @@ testthat::describe("Datanames with special symbols", { expr = { session$setInputs("teal_modules-active_tab" = "module_1") session$flushReact() + testthat::expect_setequal( - ls( - teal.code::get_env(modules_output$module_1()()), - all.names = TRUE - ), - c(".raw_data", "iris", "_a variable with spaces_") + names(modules_output$module_1()()), + c("iris", "_a variable with spaces_") ) } ) @@ -2517,7 +2515,7 @@ testthat::describe("teal.data code with a function defined", { } })), modules = modules(module("module_1", server = function(id, data) data)) - ), , + ), expr = { session$setInputs("teal_modules-active_tab" = "module_1") session$flushReact() @@ -2537,7 +2535,6 @@ testthat::describe("teal.data code with a function defined", { envir = local_env ) local(hash <- rlang::hash(deparse1(fun)), envir = local_env) - testthat::expect_setequal( trimws(strsplit( x = teal.code::get_code(modules_output$module_1()()), diff --git a/tests/testthat/test-shinytest2-data_summary.R b/tests/testthat/test-shinytest2-data_summary.R index 27cdc2918d..8793f11042 100644 --- a/tests/testthat/test-shinytest2-data_summary.R +++ b/tests/testthat/test-shinytest2-data_summary.R @@ -100,6 +100,7 @@ testthat::test_that( # nolint end: object_name. } ) + teal.data::join_keys(data) <- teal.data::join_keys( teal.data::join_key("mtcars2", "mtcars1", keys = c("am")) ) @@ -126,7 +127,7 @@ testthat::test_that( } ) -testthat::test_that("e2e: data summary table displays datasets by datanames() order if no join_keys", { +testthat::test_that("e2e: data summary table displays datasets by names() order if no join_keys", { skip_if_too_deep(5) data <- teal.data::teal_data(mtcars1 = mtcars, mtcars2 = data.frame(am = c(0, 1), test = c("a", "b"))) diff --git a/tests/testthat/test-shinytest2-teal_data_module.R b/tests/testthat/test-shinytest2-teal_data_module.R index 7ba75f4788..7df8044d6a 100644 --- a/tests/testthat/test-shinytest2-teal_data_module.R +++ b/tests/testthat/test-shinytest2-teal_data_module.R @@ -18,7 +18,6 @@ testthat::test_that("e2e: teal_data_module will have a delayed load of datasets" dataset2 <- mtcars } ) - datanames(data) <- c("dataset1", "dataset2") data }) @@ -55,7 +54,6 @@ testthat::test_that("e2e: teal_data_module shows validation errors", { shiny::need(input$new_column, "Please provide a new column name") ) data <- within(teal_data(), dataset1 <- iris) - datanames(data) <- c("dataset1") data }) }) @@ -98,7 +96,6 @@ testthat::test_that("e2e: teal_data_module inputs change teal_data object that i }, new_column = input$new_column ) - datanames(data) <- c("dataset1") data }) @@ -143,7 +140,6 @@ testthat::test_that("e2e: teal_data_module gets removed after successful data lo dataset2 <- mtcars } ) - datanames(data) <- c("dataset1", "dataset2") data }) @@ -188,7 +184,6 @@ testthat::test_that("e2e: teal_data_module is still visible after successful dat dataset2 <- mtcars } ) - datanames(data) <- c("dataset1", "dataset2") data }) @@ -228,7 +223,6 @@ testthat::test_that("e2e: teal_data_module will make other tabs inactive before dataset2 <- mtcars } ) - datanames(data) <- c("dataset1", "dataset2") data }) diff --git a/tests/testthat/test-teal_data_module-eval_code.R b/tests/testthat/test-teal_data_module-eval_code.R index 1e32bea5c3..0687c6174c 100644 --- a/tests/testthat/test-teal_data_module-eval_code.R +++ b/tests/testthat/test-teal_data_module-eval_code.R @@ -107,7 +107,7 @@ testthat::test_that("eval_code.teal_data_module propagates qenv error from the o server = function(id) { shiny::moduleServer(id, function(input, output, session) { reactive( - within(teal.data::teal_data(IRIS = iris), "non_existing_var + 1") + within(teal.data::teal_data(IRIS = iris), non_existing_var + 1) ) }) } diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index d04208a2b3..3eac0de5e6 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -41,7 +41,6 @@ testthat::test_that("report_card_template function returns TealReportCard object test_that("teal_data_to_filtered_data return FilteredData class", { teal_data <- teal.data::teal_data() teal_data <- within(teal_data, iris <- head(iris)) - datanames(teal_data) <- "iris" testthat::expect_s3_class(teal_data_to_filtered_data(teal_data), "FilteredData") }) diff --git a/vignettes/adding-support-for-reporting.Rmd b/vignettes/adding-support-for-reporting.Rmd index c26abccf8b..9c3730610b 100644 --- a/vignettes/adding-support-for-reporting.Rmd +++ b/vignettes/adding-support-for-reporting.Rmd @@ -39,7 +39,7 @@ my_module <- function(label = "example teal module") { checkmate::assert_class(isolate(data()), "teal_data") moduleServer(id, function(input, output, session) { - updateSelectInput(session, "dataname", choices = isolate(datanames(data()))) + updateSelectInput(session, "dataname", choices = isolate(names(data()))) output$dataset <- renderPrint({ req(input$dataname) data()[[input$dataname]] @@ -82,7 +82,7 @@ my_module_with_reporting <- function(label = "example teal module") { label = label, server = function(id, data, reporter) { moduleServer(id, function(input, output, session) { - updateSelectInput(session, "dataname", choices = isolate(datanames(data()))) + updateSelectInput(session, "dataname", choices = isolate(names(data()))) output$dataset <- renderPrint({ req(input$dataname) data()[[input$dataname]] @@ -130,7 +130,7 @@ my_module_with_reporting <- function(label = "example teal module") { reporter = reporter, card_fun = function(card) card ) - updateSelectInput(session, "dataname", choices = isolate(datanames(data()))) + updateSelectInput(session, "dataname", choices = isolate(names(data()))) output$dataset <- renderPrint({ req(input$dataname) data()[[input$dataname]] @@ -192,7 +192,7 @@ my_module_with_reporting <- function(label = "example teal module") { reporter = reporter, card_fun = custom_function ) - updateSelectInput(session, "dataname", choices = isolate(datanames(data()))) + updateSelectInput(session, "dataname", choices = isolate(names(data()))) output$dataset <- renderPrint({ req(input$dataname) data()[[input$dataname]] @@ -265,7 +265,7 @@ example_reporter_module <- function(label = "Example") { server = function(id, data, reporter, filter_panel_api) { with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelApi") moduleServer(id, function(input, output, session) { - updateSelectInput(session, "dataname", choices = isolate(datanames(data()))) + updateSelectInput(session, "dataname", choices = isolate(names(data()))) dat <- reactive(data()[[input$dataname]]) observe({ req(dat()) diff --git a/vignettes/creating-custom-modules.Rmd b/vignettes/creating-custom-modules.Rmd index 13be052cf4..e41c59e136 100644 --- a/vignettes/creating-custom-modules.Rmd +++ b/vignettes/creating-custom-modules.Rmd @@ -63,7 +63,7 @@ my_module <- function(label = "example teal module") { label = label, server = function(id, data) { moduleServer(id, function(input, output, session) { - updateSelectInput(session, "dataname", choices = isolate(datanames(data()))) + updateSelectInput(session, "dataname", choices = isolate(names(data()))) output$dataset <- renderPrint({ req(input$dataname) data()[[input$dataname]] @@ -113,7 +113,7 @@ srv_histogram_example <- function(id, data) { moduleServer(id, function(input, output, session) { # update dataset and variable choices # each selection stored in separate reactive expression - updateSelectInput(inputId = "datasets", choices = isolate(datanames(data()))) + updateSelectInput(inputId = "datasets", choices = isolate(names(data()))) observe({ req(dataset()) nums <- vapply(data()[[dataset()]], is.numeric, logical(1L)) diff --git a/vignettes/data-as-shiny-module.Rmd b/vignettes/data-as-shiny-module.Rmd index 48deac74cf..b87b8dc33e 100644 --- a/vignettes/data-as-shiny-module.Rmd +++ b/vignettes/data-as-shiny-module.Rmd @@ -49,7 +49,6 @@ data_module <- teal_data_module( dataset2 <- mtcars } ) - datanames(data) <- c("dataset1", "dataset2") # optional data }) }) @@ -81,7 +80,6 @@ data <- within(teal_data(), { dataset1 <- iris dataset2 <- mtcars }) -datanames(data) <- c("dataset1", "dataset2") data_module <- teal_data_module( ui = function(id) { diff --git a/vignettes/data-transform-as-shiny-module.Rmd b/vignettes/data-transform-as-shiny-module.Rmd index 94e3289a0b..be8b202019 100644 --- a/vignettes/data-transform-as-shiny-module.Rmd +++ b/vignettes/data-transform-as-shiny-module.Rmd @@ -58,7 +58,6 @@ data <- within(teal_data(), { iris <- iris mtcars <- mtcars }) -datanames(data) <- c("iris", "mtcars") my_transformers <- list( teal_transform_module( @@ -110,7 +109,6 @@ data <- within(teal_data(), { iris <- iris mtcars <- mtcars }) -datanames(data) <- c("iris", "mtcars") my_transformers <- list( teal_transform_module( diff --git a/vignettes/including-data-in-teal-applications.Rmd b/vignettes/including-data-in-teal-applications.Rmd index aedf948d3b..af972d6f86 100644 --- a/vignettes/including-data-in-teal-applications.Rmd +++ b/vignettes/including-data-in-teal-applications.Rmd @@ -135,7 +135,7 @@ In the example below, two standard `ADaM` datasets (`ADSL` and `ADTTE`) are pass # create cdisc_data data_cdisc <- cdisc_data(ADSL = teal.data::rADSL, ADTTE = teal.data::rADSL) -datanames(data_cdisc) +names(data_cdisc) join_keys(data_cdisc) ```