Skip to content

Commit

Permalink
pre-release tm_data_table document update (#667)
Browse files Browse the repository at this point in the history
part of
#624

---------

Signed-off-by: kartikeya kirar <[email protected]>
Co-authored-by: Marcin <[email protected]>
  • Loading branch information
kartikeyakirar and m7pr authored Feb 26, 2024
1 parent 33714ae commit 2d70eab
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 41 deletions.
52 changes: 26 additions & 26 deletions R/tm_data_table.R
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -247,6 +245,7 @@ srv_page_data_table <- function(id,
})
}

# UI function for the data_table module
ui_data_table <- function(id,
choices,
selected) {
Expand Down Expand Up @@ -276,6 +275,7 @@ ui_data_table <- function(id,
)
}

# Server function for the data_table module
srv_data_table <- function(id,
data,
dataname,
Expand Down
31 changes: 16 additions & 15 deletions man/tm_data_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2d70eab

Please sign in to comment.