dwrs_builder: Builds a Data Wrangling R Statement From ui Elements:

View source: R/DW_Server.R

dwrs_builderR Documentation

Builds a Data Wrangling R Statement From ui Elements:

Description

Takes the current ui elements and constructs the appropriate data wrangling command from the user input.

Usage

dwrs_builder(state)

Arguments

state

DW state from DW_fetch_state()

Value

list containing the following elements

  • isgood: Return status of the function

  • cmd: Data wrangling R command

  • action: The action being performed

  • pll: Preload list (pll) containing components to save with mk_preload.

  • desc: Verbose description of the action

  • msgs: Messages to be passed back to the user

Examples

library(formods)
# The example requires a formods DW state object
state  = DW_test_mksession()$state
state[["DW"]][["ui"]][["select_dw_element"]]          = "filter"
state[["DW"]][["ui"]][["select_fds_filter_column"]]   = "EVID"
state[["DW"]][["ui"]][["select_fds_filter_operator"]] = "=="
state[["DW"]][["ui"]][["fds_filter_rhs"]]             = 0

# This builds the data wrangling statement based on
# elemets scraped from the UI
dwb_res  = dwrs_builder(state)

# Here we evaluate the resulting command:
dwee_res = dw_eval_element(state, dwb_res[["cmd"]])

# Next we add this wrangling element to the state
state    = DW_add_wrangling_element(state, dwb_res, dwee_res)

# This creates a new data view and makes it active
state = DW_new_view(state)

# Here we can pluck out that data view from the state
current_view = DW_fetch_current_view(state)

# This will update the key in this view
current_view[["key"]] = "My new view"

# And this will place it back into the state
state = DW_set_current_view(state, current_view)

formods documentation built on April 12, 2025, 1:57 a.m.