From 7c19fff473574052ae49fb70a5e92d7ee892373b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 18:37:27 +0000 Subject: [PATCH] Update pkgdown documentation 91e000d7094389b41ec87ae5c7d98537182c0085 --- main/404.html | 13 +- main/CODE_OF_CONDUCT.html | 13 +- main/CONTRIBUTING.html | 13 +- main/LICENSE-text.html | 13 +- main/SECURITY.html | 13 +- .../adding-support-for-reporting.html | 15 +- main/articles/blueprint/actors.html | 13 +- main/articles/blueprint/dataflow.html | 13 +- main/articles/blueprint/ddl.html | 13 +- main/articles/blueprint/filter_panel.html | 13 +- main/articles/blueprint/index.html | 13 +- main/articles/blueprint/intro.html | 13 +- .../blueprint/module_encapsulation.html | 13 +- main/articles/blueprint/products_map.html | 13 +- main/articles/blueprint/qenv.html | 13 +- main/articles/creating-custom-modules.html | 13 +- main/articles/data-as-shiny-module.html | 275 ++++++++++++++++++ main/articles/filter-panel.html | 13 +- .../articles/including-adam-data-in-teal.html | 13 +- .../including-general-data-in-teal.html | 13 +- main/articles/including-mae-data-in-teal.html | 13 +- main/articles/index.html | 15 +- main/articles/preprocessing-data.html | 13 +- main/articles/teal-bs-themes.html | 13 +- main/articles/teal-options.html | 13 +- main/articles/teal.html | 13 +- main/authors.html | 20 +- main/index.html | 13 +- main/news/index.html | 32 +- main/pkgdown.yml | 3 +- main/pull_request_template.html | 13 +- main/reference/TealReportCard.html | 13 +- main/reference/TealSlicesBlock.html | 13 +- main/reference/append_module.html | 13 +- main/reference/calculate_hashes.html | 13 +- main/reference/check_filter_datanames.html | 138 +++++++++ main/reference/check_modules_datanames.html | 138 +++++++++ main/reference/deep_copy_filter.html | 13 +- main/reference/dot-datasets_to_data.html | 13 +- main/reference/example_cdisc_data.html | 13 +- main/reference/example_datasets.html | 13 +- main/reference/example_module.html | 13 +- main/reference/example_modules.html | 13 +- main/reference/filter_calls_module.html | 13 +- main/reference/filter_manager_module_srv.html | 13 +- main/reference/get_client_timezone.html | 13 +- main/reference/get_code_tdata.html | 13 +- main/reference/get_datasets_code.html | 13 +- main/reference/get_join_keys.html | 13 +- main/reference/get_metadata.html | 13 +- main/reference/get_rcode_libraries.html | 13 +- main/reference/get_teal_bs_theme.html | 13 +- main/reference/include_css_files.html | 13 +- main/reference/include_js_files.html | 13 +- main/reference/include_teal_css_js.html | 13 +- main/reference/index.html | 18 +- main/reference/init.html | 18 +- main/reference/is_arg_used.html | 13 +- main/reference/landing_popup_module.html | 21 +- main/reference/matrix_to_mapping.html | 13 +- main/reference/module.html | 13 +- main/reference/module_filter_manager.html | 13 +- .../module_filter_manager_modal.html | 13 +- main/reference/module_management.html | 13 +- main/reference/module_nested_tabs.html | 13 +- main/reference/module_tabs_with_filters.html | 13 +- main/reference/module_teal.html | 23 +- main/reference/modules.html | 13 +- main/reference/modules_depth.html | 13 +- main/reference/reexports.html | 13 +- main/reference/report_card_template.html | 13 +- main/reference/reporter_previewer_module.html | 13 +- main/reference/resolve_modules_datanames.html | 13 +- main/reference/run_js_files.html | 13 +- main/reference/show_rcode_modal.html | 13 +- main/reference/slices_restore.html | 13 +- main/reference/slices_store.html | 13 +- main/reference/snapshot_manager_module.html | 16 +- main/reference/srv_teal_with_splash.html | 18 +- main/reference/tdata.html | 13 +- main/reference/tdata2env.html | 13 +- main/reference/teal-package.html | 13 +- main/reference/teal_data_module.html | 170 +++++++++++ .../reference/teal_data_to_filtered_data.html | 13 +- main/reference/teal_slices.html | 13 +- main/reference/ui_teal_with_splash.html | 18 +- main/reference/unfold_mapping.html | 13 +- main/reference/validate_has_data.html | 13 +- main/reference/validate_has_elements.html | 13 +- main/reference/validate_has_variable.html | 13 +- main/reference/validate_in.html | 13 +- main/reference/validate_inputs.html | 13 +- main/reference/validate_n_levels.html | 13 +- main/reference/validate_no_intersection.html | 13 +- main/reference/validate_one_row_per_id.html | 13 +- main/search.json | 2 +- main/sitemap.xml | 12 + 97 files changed, 961 insertions(+), 1018 deletions(-) create mode 100644 main/articles/data-as-shiny-module.html create mode 100644 main/reference/check_filter_datanames.html create mode 100644 main/reference/check_modules_datanames.html create mode 100644 main/reference/teal_data_module.html diff --git a/main/404.html b/main/404.html index 16a9e89f95..03ea0dc1de 100644 --- a/main/404.html +++ b/main/404.html @@ -25,7 +25,7 @@ teal - 0.14.0.9016 + 0.14.0.9017
part of NESTpharmaverse
+ + + + + +
+ + + + +
+
+ + + +
+

Introduction +

+

Proper functioning of any teal application requires +presence of a teal_data object. Typically, a +teal_data object created in the global environment will be +passed to the data argument in init. This +teal_data object should contain all elements necessary for +successful execution of the application’s modules. In some scenarios, +however, application developers may opt to postpone some data operations +until the application run time. This can be done by passing a special +shiny module to the data argument. +The teal_data_module function is used to build such a +module from the following components:

+
    +
  • a ui function; accepts only one argument, +id; defines user interface elements for the data +module
  • +
  • a server function: accepts only one argument, +id; defines server logic for the data module, including +data creation; must return a reactive expression containing a +teal_data object
  • +
+

teal will run this module when the application starts +and the resulting teal_data object that will be used +throughout all teal (analytic) modules.

+
+
+

Creating Data In-App +

+

One case for postponing data operations are data sets that are +dynamic, frequently updated. Such data cannot be created once and kept +in the global environment. Using teal_data_module allows to +create a data set from scratch every time the user starts the +application.

+ +
+data_mod <- teal_data_module(
+  ui = function(id) div(),
+  server = function(id) {
+    moduleServer(id, function(input, output, session) {
+      reactive({
+        data <- within(
+          teal_data(),
+          {
+            dataset1 <- iris
+            dataset2 <- mtcars
+          }
+        )
+        datanames(data) <- c("dataset1", "dataset2")
+        data
+      })
+    })
+  }
+)
+
+
+app <- init(
+  data = data_mod,
+  module = example_module()
+)
+
+if (interactive()) {
+  shinyApp(app$ui, app$server)
+}
+
+
+

Modification Data In-App +

+

Another reason to postpone data operations is to allow the +application user to act the preprocessing stage. An initial, constant +form of the data can be created in the global environment and then +modified once the app starts.

+

The following example illustrates how teal_data_module +can be utilized to subset data based on the user inputs:

+
+data <- within(teal_data(), {
+  dataset1 <- iris
+  dataset2 <- mtcars
+})
+datanames(data) <- c("dataset1", "dataset2")
+
+data_mod <- teal_data_module(
+  ui = function(id) {
+    ns <- NS(id)
+    div(
+      selectInput(ns("species"), "Select species to filter",
+        choices = unique(iris$Species), multiple = TRUE
+      ),
+      actionButton(ns("submit"), "Submit")
+    )
+  },
+  server = function(id) {
+    moduleServer(id, function(input, output, session) {
+      eventReactive(input$submit, {
+        data_modified <- within(
+          data,
+          dataset1 <- subset(dataset1, Species %in% selected),
+          selected = input$species
+        )
+        data_modified
+      })
+    })
+  }
+)
+
+app <- init(
+  data = data_mod,
+  module = example_module()
+)
+
+if (interactive()) {
+  shinyApp(app$ui, app$server)
+}
+

See ?within.qenv for a detailed explanation of how +to use the within method.

+

Note that running preprocessing code in a module as opposed to the +global environment will increase app loading times. It is recommended to +keep the constant code in the global environment and to move only the +dynamic parts to a data module.

+
+
WARNING +
+

When using teal_data_module to modify a pre-existing +teal_data object it is crucial that the server function and +the data object are defined in the same environment as otherwise the +server function will not be able to access the data object. This means +server functions defined in packages cannot be used.

+
+
+
+
+ + + + +
+ + + + + + + diff --git a/main/articles/filter-panel.html b/main/articles/filter-panel.html index d8ebead518..b7bae78f1f 100644 --- a/main/articles/filter-panel.html +++ b/main/articles/filter-panel.html @@ -27,7 +27,7 @@ teal - 0.14.0.9016 + 0.14.0.9017
part of NESTpharmaverse
+ + + + + +
+
+
+ +
+

This function checks whether datanames in filters correspond to those in data, +returning character vector with error messages or TRUE if all checks pass.

+
+ +
+

Usage

+
check_filter_datanames(filters, datanames)
+
+ +
+

Arguments

+
filters
+

(teal_slices) object

+ + +
datanames
+

(character) names of datasets available in the data object

+ +
+
+

Value

+ + +

A character(1) containing error message or TRUE if validation passes.

+
+ +
+ + +
+ + + + + + + diff --git a/main/reference/check_modules_datanames.html b/main/reference/check_modules_datanames.html new file mode 100644 index 0000000000..497073c8ea --- /dev/null +++ b/main/reference/check_modules_datanames.html @@ -0,0 +1,138 @@ + +Check datanames in modules — check_modules_datanames • teal + Skip to contents + + +
+
+
+ +
+

This function ensures specified datanames in modules match those in the data object, +returning error messages or TRUE for successful validation.

+
+ +
+

Usage

+
check_modules_datanames(modules, datanames)
+
+ +
+

Arguments

+
modules
+

(teal_modules) object

+ + +
datanames
+

(character) names of datasets available in the data object

+ +
+
+

Value

+ + +

A character(1) containing error message or TRUE if validation passes.

+
+ +
+ + +
+ + + + + + + diff --git a/main/reference/deep_copy_filter.html b/main/reference/deep_copy_filter.html index 5b51bc09e9..64bd176d99 100644 --- a/main/reference/deep_copy_filter.html +++ b/main/reference/deep_copy_filter.html @@ -16,7 +16,7 @@ teal - 0.14.0.9016 + 0.14.0.9017
part of NESTpharmaverse
+ + + + + +
+
+
+ +
+

Creates teal_data_module object - a shiny module to supply or modify data in a teal application.

+
+ +
+

Usage

+
teal_data_module(ui, server)
+
+ +
+

Arguments

+
ui
+

(function(id))
shiny module ui function; must only take id argument

+ + +
server
+

(function(id))
shiny module ui function; must only take id argument; +must return reactive expression containing teal_data object

+ +
+
+

Value

+ + +

Object of class teal_data_module.

+
+
+

Details

+

This function creates a shiny module that allows for running data pre-processing code after the app starts. +The body of the server function will be run in the app rather than in the global environment. +This means it will be run every time the app starts, so use sparingly.

+

Pass this module instead of a teal_data object in a call to init().

+

See vignette vignette("data-as-shiny-module", package = "teal") for more details.

+
+ +
+

Examples

+
data <- teal_data_module(
+  ui = function(id) {
+    ns <- NS(id)
+    actionButton(ns("submit"), label = "Load data")
+  },
+  server = function(id) {
+    moduleServer(id, function(input, output, session) {
+      eventReactive(input$submit, {
+        data <- within(
+          teal_data(),
+          {
+            dataset1 <- iris
+            dataset2 <- mtcars
+          }
+        )
+        datanames(data) <- c("iris", "mtcars")
+
+        data
+      })
+    })
+  }
+)
+
+
+
+ + +
+ + + + + + + diff --git a/main/reference/teal_data_to_filtered_data.html b/main/reference/teal_data_to_filtered_data.html index a9168cd874..7fb80e27e0 100644 --- a/main/reference/teal_data_to_filtered_data.html +++ b/main/reference/teal_data_to_filtered_data.html @@ -10,7 +10,7 @@ teal - 0.14.0.9016 + 0.14.0.9017
part of NESTpharmaverse