dataUploadServer: Shiny server module function for user-uploaded data

View source: R/dataUpload.R

dataUploadServerR Documentation

Shiny server module function for user-uploaded data

Description

Return reactive user-uploaded or mock data after optional checks and modifications

Usage

dataUploadServer(
  id,
  asDT = TRUE,
  removable = FALSE,
  checkFun = NULL,
  appdata = NULL,
  checkappdata = F,
  informd = NULL
)

Arguments

id

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

asDT

Logical flag to indicate whether data returned should be a data.table. If FALSE, readLines is used on file.

removable

Logical flag to indicate whether data upload will have "removable" feature. Defaults to FALSE. See details.

checkFun

Optional, a custom check function for an additional layer of checking/modifying uploaded data. It should return a list containing message and result (result should be NULL when data fails checks).

appdata

Optional, the path of one or more files that can be mock-uploaded. See details.

checkappdata

Whether checkFun should be applied to appdata, normally FALSE.

informd

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

Details

At its most basic, the module returns data from shiny::fileInput. However, a function can be optionally integrated with the checkFun option to perform additional light data checking or modification operations, making the the module more tailored for different uses and data expectations. (For more intense processing that might involve multiple steps and/or side effects as part of a pipeline, one should really make a specialized module and pass the data into that intermediate module instead of using checkFun.)

File uploads can have reset behavior by specifying the removable parameter, where a remove button will appear after upload, allowing data to be cleared, after which the module returns NULL.

Finally, it is possible to perform a mock upload of a saved dataset, triggered externally by another input, for demonstration purposes. The dataset is expected to be a .csv/.tsv file in a directory within the app directory. For instance, the relative dataset path can be "appdata/Demo.csv".

Value

A data.table with a "filename" attribute containing the filename without extension, or NULL depending on checkFun, or NULL if the file was cleared.

See Also

Other dataUpload functions: dataUploadUI()


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