From 2d70eabdbfff79508e39470666e83c9d15206bd9 Mon Sep 17 00:00:00 2001 From: kartikeya kirar Date: Mon, 26 Feb 2024 19:41:49 +0530 Subject: [PATCH] pre-release ` tm_data_table` document update (#667) part of https://github.com/insightsengineering/teal.modules.general/issues/624 --------- Signed-off-by: kartikeya kirar Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/tm_data_table.R | 52 ++++++++++++++++++++++---------------------- man/tm_data_table.Rd | 31 +++++++++++++------------- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/R/tm_data_table.R b/R/tm_data_table.R index df7888227..9d6cd866c 100644 --- a/R/tm_data_table.R +++ b/R/tm_data_table.R @@ -1,34 +1,34 @@ -#' Data Table Viewer `teal` Module +#' Data table viewer module #' -#' A data table viewer shows the data using a paginated table. -#' specifically designed for use with `data.frames`. -#' @md +#' Module provides a dynamic and interactive way to view `data.frame`s in a `teal` application. +#' It uses the `DT` package to display data tables in a paginated, searchable, and sortable format, +#' which helps to enhance data exploration and analysis. +#' +#' The `DT` package has an option `DT.TOJSON_ARGS` to show `Inf` and `NA` in data tables. +#' Configure the `DT.TOJSON_ARGS` option via +#' `options(DT.TOJSON_ARGS = list(na = "string"))` before running the module. +#' Note though that sorting of numeric columns with `NA`/`Inf` will be lexicographic not numerical. #' #' @inheritParams teal::module #' @inheritParams shared_params -#' @param variables_selected (`list`) A named list of character vectors of the variables (i.e. columns) -#' which should be initially shown for each dataset. Names of list elements should correspond to the names -#' of the datasets available in the app. If no entry is specified for a dataset, the first six variables from that -#' dataset will initially be shown. +#' @param variables_selected (`named list`) Character vectors of the variables (i.e. columns) +#' which should be initially shown for each dataset. +#' Names of list elements should correspond to the names of the datasets available in the app. +#' If no entry is specified for a dataset, the first six variables from that +#' dataset will initially be shown. #' @param datasets_selected (`character`) A vector of datasets which should be -#' shown and in what order. Names in the vector have to correspond with datasets names. -#' If vector of length zero (default) then all datasets are shown. -#' Note: Only datasets of the `data.frame` class are compatible; -#' using other types will cause an error. -#' @param dt_args (named `list`) Additional arguments to be passed to `DT::datatable` -#' (must not include `data` or `options`). -#' @param dt_options (named `list`) The `options` argument to `DT::datatable`. By default -#' `list(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100), scrollX = TRUE)` +#' shown and in what order. Names in the vector have to correspond with datasets names. +#' If vector of `length == 0` (default) then all datasets are shown. +#' Note: Only datasets of the `data.frame` class are compatible. +#' @param dt_args (`named list`) Additional arguments to be passed to [DT::datatable()] +#' (must not include `data` or `options`). +#' @param dt_options (`named list`) The `options` argument to `DT::datatable`. By default +#' `list(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100), scrollX = TRUE)` #' @param server_rendering (`logical`) should the data table be rendered server side -#' (see `server` argument of `DT::renderDataTable()`) -#' @details -#' The `DT` package has an option `DT.TOJSON_ARGS` to show `Inf` and `NA` in data tables. If this is something -#' you require then set `options(DT.TOJSON_ARGS = list(na = "string"))` before running the module. -#' Note though that sorting of numeric columns with `NA`/`Inf` will be lexicographic not numerical. +#' (see `server` argument of [DT::renderDataTable()]) #' #' @examples #' # general data example -#' #' data <- teal_data() #' data <- within(data, { #' require(nestcolor) @@ -127,8 +127,7 @@ tm_data_table <- function(label = "Data Table", ) } - -# ui page module +# UI page module ui_page_data_table <- function(id, pre_output = NULL, post_output = NULL) { @@ -162,8 +161,7 @@ ui_page_data_table <- function(id, ) } - -# server page module +# Server page module srv_page_data_table <- function(id, data, datasets_selected, @@ -247,6 +245,7 @@ srv_page_data_table <- function(id, }) } +# UI function for the data_table module ui_data_table <- function(id, choices, selected) { @@ -276,6 +275,7 @@ ui_data_table <- function(id, ) } +# Server function for the data_table module srv_data_table <- function(id, data, dataname, diff --git a/man/tm_data_table.Rd b/man/tm_data_table.Rd index 8cbdde1f0..3b4136be5 100644 --- a/man/tm_data_table.Rd +++ b/man/tm_data_table.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/tm_data_table.R \name{tm_data_table} \alias{tm_data_table} -\title{Data Table Viewer \code{teal} Module} +\title{Data table viewer module} \usage{ tm_data_table( label = "Data Table", @@ -20,25 +20,25 @@ tm_data_table( \item{label}{(\code{character(1)}) Label shown in the navigation item for the module or module group. For \code{modules()} defaults to \code{"root"}. See \code{Details}.} -\item{variables_selected}{(\code{list}) A named list of character vectors of the variables (i.e. columns) -which should be initially shown for each dataset. Names of list elements should correspond to the names -of the datasets available in the app. If no entry is specified for a dataset, the first six variables from that +\item{variables_selected}{(\verb{named list}) Character vectors of the variables (i.e. columns) +which should be initially shown for each dataset. +Names of list elements should correspond to the names of the datasets available in the app. +If no entry is specified for a dataset, the first six variables from that dataset will initially be shown.} \item{datasets_selected}{(\code{character}) A vector of datasets which should be shown and in what order. Names in the vector have to correspond with datasets names. -If vector of length zero (default) then all datasets are shown. -Note: Only datasets of the \code{data.frame} class are compatible; -using other types will cause an error.} +If vector of \code{length == 0} (default) then all datasets are shown. +Note: Only datasets of the \code{data.frame} class are compatible.} -\item{dt_args}{(named \code{list}) Additional arguments to be passed to \code{DT::datatable} +\item{dt_args}{(\verb{named list}) Additional arguments to be passed to \code{\link[DT:datatable]{DT::datatable()}} (must not include \code{data} or \code{options}).} -\item{dt_options}{(named \code{list}) The \code{options} argument to \code{DT::datatable}. By default +\item{dt_options}{(\verb{named list}) The \code{options} argument to \code{DT::datatable}. By default \code{list(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100), scrollX = TRUE)}} \item{server_rendering}{(\code{logical}) should the data table be rendered server side -(see \code{server} argument of \code{DT::renderDataTable()})} +(see \code{server} argument of \code{\link[DT:dataTableOutput]{DT::renderDataTable()}})} \item{pre_output}{(\code{shiny.tag}, optional)\cr with text placed before the output to put the output into context. For example a title.} @@ -47,17 +47,18 @@ with text placed before the output to put the output into context. For example a into context. For example the \code{\link[shiny:helpText]{shiny::helpText()}} elements are useful.} } \description{ -A data table viewer shows the data using a paginated table. -specifically designed for use with \code{data.frames}. +Module provides a dynamic and interactive way to view \code{data.frame}s in a \code{teal} application. +It uses the \code{DT} package to display data tables in a paginated, searchable, and sortable format, +which helps to enhance data exploration and analysis. } \details{ -The \code{DT} package has an option \code{DT.TOJSON_ARGS} to show \code{Inf} and \code{NA} in data tables. If this is something -you require then set \code{options(DT.TOJSON_ARGS = list(na = "string"))} before running the module. +The \code{DT} package has an option \code{DT.TOJSON_ARGS} to show \code{Inf} and \code{NA} in data tables. +Configure the \code{DT.TOJSON_ARGS} option via +\code{options(DT.TOJSON_ARGS = list(na = "string"))} before running the module. Note though that sorting of numeric columns with \code{NA}/\code{Inf} will be lexicographic not numerical. } \examples{ # general data example - data <- teal_data() data <- within(data, { require(nestcolor)