DW_set_current_view {formods}R Documentation

Sets Current Data View

Description

Takes a DW state and an updated view and sets that view to the current view_id

Usage

DW_set_current_view(state, dw_view)

Arguments

state

DW state from DW_fetch_state()

dw_view

Data view list of the format returned from DW_fetch_current_view() (see the structure of state$DW$views in the output of DW_fetch_state()).

Value

DW state object with the value of dw_view set to the current view id.

Examples

library(formods)
# The example requires a formods DW state object
state  = DW_test_mksession(session=list())$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)

[Package formods version 0.1.4 Index]