Skip to contents

Loops through each specified module ID or all modules if no ID was specified. For each ID, an attempt will be made to extract any datasets available.

Usage

FM_fetch_ds(state, session, ids = NULL)

Arguments

state

Current module state after yaml file has been read

session

Shiny session variable

ids

Vector of ID strings for the modules containing the datasets or NULL for all datasets available.

Value

list containing the current dataset with the following format:

  • isgood: Boolean indicating the whether a dataset was found (FALSE)

  • ds: List of datasets with element names corresponding to the R object name for that dataset. This has the following format

    • label: Text label for the dataset (used to display to the user)

    • DS: Data frame with the dataset

    • DSMETA: Data frame with metadata about the colunns of the dataset in DS. The data frame should have the following columns:

      • col1: column 1

    • code: Code to generate the dataset.

    • checksum: Module checksum when the dataset was pulled

    • DSchecksum: Checksum of the dataframe in DS

  • catalog: Dataframe containing the a tabular catalog of the datasets found.

    • label: Text label

    • object: Name of the R Object containing the data frame

    • MOD_TYPE: Short name of the type of module

    • id: Module ID

    • idx: Numerical identifyer within the module

    • checksum: Module checksum

    • DSchecksum: Checksum of the dataset

    • code: Code to generate the dataset

  • modules: List with an entry for each module. The element name is the short name. Each of these is a list with an entry that is the shiny module ID. For each of these there is a checksum. For example to access the checksum of a DW module with a module ID of 'my_id', you would use the following: res$modules$DW$my_id.

Examples

# We need a module state and a Shiny session variable
# to use this function:
sess_res = UD_test_mksession()
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → ASM:   dest:   file.path("config","report.docx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → ASM:   dest:   file.path("config","report.pptx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → ASM:   dest:   file.path("config","report.yaml")
#> → ASM: State initialized
#> → ASM: setting word placeholders: 
#> → ASM:   -> setting docx ph: HEADERLEFT = left header
#> → ASM:   -> setting docx ph: HEADERRIGHT = right header
#> → ASM:   -> setting docx ph: FOOTERLEFT = left footer
#> → ASM: module isgood: TRUE
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → UD:   dest:   file.path("config","report.docx")
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → UD:   dest:   file.path("config","report.pptx")
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → UD:   dest:   file.path("config","report.yaml")
#> → UD: State initialized
#> → UD: module checksum updated:897d952fecbc804999396a96f9df4b20
#> → UD: module isgood: TRUE
session = sess_res$session
state   = sess_res$state
ds = FM_fetch_ds(state, session)
ds$catalog
#>               label object MOD_TYPE id idx                         checksum
#> 1 Original data set   myDS       UD UD   1 897d952fecbc804999396a96f9df4b20
#>                         DSchecksum
#> 1 897d952fecbc804999396a96f9df4b20
#>                                                                                                             code
#> 1 myDS = readxl::read_excel(path="TEST_DATA.xlsx", sheet="DATA")\nmyDS = janitor::clean_names(myDS, case="none")