data_helpers | R Documentation |
Various helpers to simulate data and to manipulate data types between compact and long forms.
Take a 'data.frame' and return compact 'data.frame' of event types and strategies.
collapse_data(
data,
model,
drop_NA = TRUE,
drop_family = FALSE,
summary = FALSE
)
expand_data(data_events = NULL, model)
data |
A |
model |
A |
drop_NA |
Logical. Whether to exclude strategy families that contain no observed data. Exceptionally if no data is provided, minimal data on data on first node is returned. Defaults to 'TRUE' |
drop_family |
Logical. Whether to remove column |
summary |
Logical. Whether to return summary of the data. See details. Defaults to 'FALSE'. |
data_events |
A |
A vector of data events
If summary = TRUE
'collapse_data' returns a list containing the
following components:
data_events |
A compact data.frame of event types and strategies. |
observed_events |
A vector of character strings specifying the events observed in the data |
unobserved_events |
A vector of character strings specifying the events not observed in the data |
A data.frame
with rows as data observation
model <- make_model('X -> Y')
df <- data.frame(X = c(0,1,NA), Y = c(0,0,1))
df |> collapse_data(model)
# Illustrating options
df |> collapse_data(model, drop_NA = FALSE)
df |> collapse_data(model, drop_family = TRUE)
df |> collapse_data(model, summary = TRUE)
# Appropriate behavior given restricted models
model <- make_model('X -> Y') |>
set_restrictions('X[]==1')
df <- make_data(model, n = 10)
df[1,1] <- ''
df |> collapse_data(model)
df <- data.frame(X = 0:1)
df |> collapse_data(model)
model <- make_model('X->M->Y')
make_events(model, n = 5) |>
expand_data(model)
make_events(model, n = 0) |>
expand_data(model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.