dataSubsetServer: Shiny server module for returning a subsetted dataset

View source: R/dataSubset.R

dataSubsetServerR Documentation

Shiny server module for returning a subsetted dataset

Description

Create a reactive subsetted dataset based on user selection

Usage

dataSubsetServer(
  id,
  dataset,
  subsetv,
  subsets = NULL,
  customdata = NULL,
  informd = NULL
)

Arguments

id

Character ID for specifying namespace, see shiny::NS.

dataset

A data.table.

subsetv

Name of the subset-by variable in the data.

subsets

Optional, a list to display groups with higher-level grouping in the selection. By default, the selection is composed of unique values in subsetv.

customdata

Optional, a length-one character vector of data column to append. See details.

informd

Relative path to the Rmarkdown file, whose contents will be displayed in the modal.

Details

This modularizes the usual means of subsetting data by selecting group(s) in a variable. There can be several of these modules to create subsets from the same dataset, e.g. two modules with different grouping variables given to subsetv, or to create subsets from different datasets. The only potentially interesting extra option is customdata, which appends a column to the subsetted result and exists for different purposes. When there are several instances of the module for creating subsets from different datasets, appending a customdata column could be useful to track the dataset origin of the subset, especially if the subset data are to be merged with other data into one dataset later on. For example, for two datasets that come from different sources, customdata can be passed in as c(Source="S1") for the first module and c(Source="S2") for the second. Alternatively, customdata can be useful for appending custom data such as c(Color="red"), perhaps to use in plotting of the subsetted data.

Note: currently, multi-selection is a non-configurable default.

Value

A reactive data.table representing a subset of dataset.

See Also

Other dataSubset functions: dataSubsetInput()


avucoh/DIVE documentation built on Aug. 29, 2023, 6:02 p.m.