Skip to content

Commit 2d70eab

Browse files
kartikeyakirarm7pr
andauthored
pre-release tm_data_table document update (#667)
part of #624 --------- Signed-off-by: kartikeya kirar <kirar.kartikeya1@gmail.com> Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com>
1 parent 33714ae commit 2d70eab

File tree

2 files changed

+42
-41
lines changed

2 files changed

+42
-41
lines changed

R/tm_data_table.R

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
#' Data Table Viewer `teal` Module
1+
#' Data table viewer module
22
#'
3-
#' A data table viewer shows the data using a paginated table.
4-
#' specifically designed for use with `data.frames`.
5-
#' @md
3+
#' Module provides a dynamic and interactive way to view `data.frame`s in a `teal` application.
4+
#' It uses the `DT` package to display data tables in a paginated, searchable, and sortable format,
5+
#' which helps to enhance data exploration and analysis.
6+
#'
7+
#' The `DT` package has an option `DT.TOJSON_ARGS` to show `Inf` and `NA` in data tables.
8+
#' Configure the `DT.TOJSON_ARGS` option via
9+
#' `options(DT.TOJSON_ARGS = list(na = "string"))` before running the module.
10+
#' Note though that sorting of numeric columns with `NA`/`Inf` will be lexicographic not numerical.
611
#'
712
#' @inheritParams teal::module
813
#' @inheritParams shared_params
9-
#' @param variables_selected (`list`) A named list of character vectors of the variables (i.e. columns)
10-
#' which should be initially shown for each dataset. Names of list elements should correspond to the names
11-
#' of the datasets available in the app. If no entry is specified for a dataset, the first six variables from that
12-
#' dataset will initially be shown.
14+
#' @param variables_selected (`named list`) Character vectors of the variables (i.e. columns)
15+
#' which should be initially shown for each dataset.
16+
#' Names of list elements should correspond to the names of the datasets available in the app.
17+
#' If no entry is specified for a dataset, the first six variables from that
18+
#' dataset will initially be shown.
1319
#' @param datasets_selected (`character`) A vector of datasets which should be
14-
#' shown and in what order. Names in the vector have to correspond with datasets names.
15-
#' If vector of length zero (default) then all datasets are shown.
16-
#' Note: Only datasets of the `data.frame` class are compatible;
17-
#' using other types will cause an error.
18-
#' @param dt_args (named `list`) Additional arguments to be passed to `DT::datatable`
19-
#' (must not include `data` or `options`).
20-
#' @param dt_options (named `list`) The `options` argument to `DT::datatable`. By default
21-
#' `list(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100), scrollX = TRUE)`
20+
#' shown and in what order. Names in the vector have to correspond with datasets names.
21+
#' If vector of `length == 0` (default) then all datasets are shown.
22+
#' Note: Only datasets of the `data.frame` class are compatible.
23+
#' @param dt_args (`named list`) Additional arguments to be passed to [DT::datatable()]
24+
#' (must not include `data` or `options`).
25+
#' @param dt_options (`named list`) The `options` argument to `DT::datatable`. By default
26+
#' `list(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100), scrollX = TRUE)`
2227
#' @param server_rendering (`logical`) should the data table be rendered server side
23-
#' (see `server` argument of `DT::renderDataTable()`)
24-
#' @details
25-
#' The `DT` package has an option `DT.TOJSON_ARGS` to show `Inf` and `NA` in data tables. If this is something
26-
#' you require then set `options(DT.TOJSON_ARGS = list(na = "string"))` before running the module.
27-
#' Note though that sorting of numeric columns with `NA`/`Inf` will be lexicographic not numerical.
28+
#' (see `server` argument of [DT::renderDataTable()])
2829
#'
2930
#' @examples
3031
#' # general data example
31-
#'
3232
#' data <- teal_data()
3333
#' data <- within(data, {
3434
#' require(nestcolor)
@@ -127,8 +127,7 @@ tm_data_table <- function(label = "Data Table",
127127
)
128128
}
129129

130-
131-
# ui page module
130+
# UI page module
132131
ui_page_data_table <- function(id,
133132
pre_output = NULL,
134133
post_output = NULL) {
@@ -162,8 +161,7 @@ ui_page_data_table <- function(id,
162161
)
163162
}
164163

165-
166-
# server page module
164+
# Server page module
167165
srv_page_data_table <- function(id,
168166
data,
169167
datasets_selected,
@@ -247,6 +245,7 @@ srv_page_data_table <- function(id,
247245
})
248246
}
249247

248+
# UI function for the data_table module
250249
ui_data_table <- function(id,
251250
choices,
252251
selected) {
@@ -276,6 +275,7 @@ ui_data_table <- function(id,
276275
)
277276
}
278277

278+
# Server function for the data_table module
279279
srv_data_table <- function(id,
280280
data,
281281
dataname,

man/tm_data_table.Rd

Lines changed: 16 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)