From 8c41179110e4a1406c856e271bf3d213e4111d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:43:10 +0000 Subject: [PATCH] chore: cleanup of @env get_env and other mentions --- R/dummy_functions.R | 2 +- R/init.R | 6 +-- R/module_data_summary.R | 5 ++- R/module_init_data.R | 4 +- R/module_nested_tabs.R | 4 +- R/module_teal.R | 2 +- R/module_teal_data.R | 2 +- R/teal_data_module.R | 1 - R/teal_data_utils.R | 13 +++---- R/utils.R | 6 +-- man/dot-get_hashes_code.Rd | 2 +- man/teal_data_module.Rd | 1 - man/teal_data_to_filtered_data.Rd | 4 +- man/teal_data_utilities.Rd | 4 +- tests/testthat/helper-shinytest2.R | 3 +- tests/testthat/test-module_teal.R | 39 +++++++++---------- tests/testthat/test-shinytest2-data_summary.R | 4 +- .../test-shinytest2-teal_data_module.R | 6 --- .../test-teal_data_module-eval_code.R | 2 +- tests/testthat/test-utils.R | 1 - vignettes/adding-support-for-reporting.Rmd | 10 ++--- vignettes/creating-custom-modules.Rmd | 4 +- vignettes/data-as-shiny-module.Rmd | 2 - vignettes/data-transform-as-shiny-module.Rmd | 2 - .../including-data-in-teal-applications.Rmd | 2 +- 25 files changed, 56 insertions(+), 75 deletions(-) diff --git a/R/dummy_functions.R b/R/dummy_functions.R index fd3f067699..5c05ad24a1 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(ls((req(data())))) observeEvent(datanames_rv(), { selected <- input$dataname if (identical(selected, "")) { diff --git a/R/init.R b/R/init.R index 005bc448f9..76847c01a4 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(ls(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, ls(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, ls(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 e793c53f70..5b43ae5263 100644 --- a/R/module_data_summary.R +++ b/R/module_data_summary.R @@ -62,7 +62,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(ls(teal_data()))) { return(NULL) } @@ -138,7 +138,8 @@ srv_data_summary <- function(id, teal_data) { #' @rdname module_data_summary get_filter_overview <- function(teal_data) { - datanames <- teal.data::datanames(teal_data()) + # Sort datanames in topological order + datanames <- intersect(names(teal_data()), ls(teal_data())) joinkeys <- teal.data::join_keys(teal_data()) filtered_data_objs <- sapply( diff --git a/R/module_init_data.R b/R/module_init_data.R index f2a39ce6e0..3022081206 100644 --- a/R/module_init_data.R +++ b/R/module_init_data.R @@ -102,7 +102,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)), + ls(data), teal.code::get_var, object = data, simplify = FALSE @@ -122,7 +122,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 = ls(data)) { vapply( datanames, function(dataname, datasets) { diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index deb83cc59f..ec307100c6 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)) + .topologically_sort_datanames(ls(data), teal.data::join_keys(data)) } else { intersect( .include_parent_datanames(modules$datanames, teal.data::join_keys(data)), - ls(teal.code::get_env(data)) + ls(data) ) } } diff --git a/R/module_teal.R b/R/module_teal.R index 3e913c2340..70383cc749 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, ls(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..7dfc9f025c 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 = ls(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..b023449410 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, ls(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 0397774e7b..22ca06d9eb 100644 --- a/R/utils.R +++ b/R/utils.R @@ -71,10 +71,10 @@ 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 `ls(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 = ls(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 @@ -328,7 +328,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..8069825079 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 = ls(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..ecf96f66a1 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 = ls(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{ls(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..bc058e6f92 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(ls(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 2fa450ed60..2704005759 100644 --- a/tests/testthat/test-module_teal.R +++ b/tests/testthat/test-module_teal.R @@ -489,9 +489,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(ls(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(ls(modules_output$module_2()()), "mtcars") } ) }) @@ -545,7 +545,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(ls(modules_output$module_1()()), "iris") testthat::expect_identical(modules_output$module_1()()[["iris"]], iris) } ) @@ -675,12 +675,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(ls(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( @@ -696,7 +696,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()()), + ls(modules_output$module_1()()), c("iris", "iris_raw", "mtcars", "swiss") ) } @@ -760,7 +760,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(ls(modules_output$module_1()()), c("iris", "mtcars", "swiss")) } ) }) @@ -797,7 +797,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(ls(modules_output$module_1()()), c("iris", "mtcars", "swiss")) } ) }) @@ -858,7 +858,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(ls(modules_output$module_1()()), c("iris", "mtcars", "swiss")) } ) }) @@ -896,7 +896,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(ls(modules_output$module_1()()), c("iris", "mtcars")) } ) }) @@ -2165,7 +2165,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")) @@ -2324,10 +2327,7 @@ testthat::describe("Datanames with special symbols", { session$flushReact() testthat::expect_setequal( - ls( - teal.code::get_env(modules_output$module_1()()), - all.names = TRUE - ), + names(modules_output$module_1()()), c(".raw_data", "iris", "%a_pipe%") ) } @@ -2355,11 +2355,9 @@ 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 - ), + names(modules_output$module_1()()), c(".raw_data", "iris", "_a variable with spaces_") ) } @@ -2451,7 +2449,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() @@ -2471,7 +2469,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 c97c861110..d7b38dedb3 100644 --- a/tests/testthat/test-shinytest2-data_summary.R +++ b/tests/testthat/test-shinytest2-data_summary.R @@ -107,8 +107,6 @@ testthat::test_that( } ) - datanames(data) <- c("CO2", "iris", "miniACC", "mtcars2", "mtcars1", "factors") - teal.data::join_keys(data) <- teal.data::join_keys( teal.data::join_key("mtcars2", "mtcars1", keys = c("am")) ) @@ -135,7 +133,7 @@ testthat::test_that( } ) -testthat::test_that("e2e: data summary displays datasets by datanames() order if no join_keys", { +testthat::test_that("e2e: data summary displays datasets by ls() 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 41c06581b6..90c9ebdd1b 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..0d905714ad 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(ls(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(ls(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(ls(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(ls(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(ls(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..3ab153b27d 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(ls(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(ls(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..cbeba0e08d 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) +ls(data_cdisc) join_keys(data_cdisc) ```