View source: R/forestsearch_helpers.R
| get_dfpred | R Documentation |
Creates a prediction dataset with a treatment recommendation flag based
on the subgroup definition. Supports both label expressions
(e.g., "\{er <= 0\}") and bare column names (e.g., "q3.1").
get_dfpred(df.predict, sg.harm, version = 1)
df.predict |
Data frame for prediction (test or validation set). |
sg.harm |
Character vector of subgroup-defining labels. Values may
be wrapped in braces and optionally negated, e.g. |
version |
Integer; encoding version (maintained for backward compatibility). Default: 1. |
Each element of sg.harm is processed as follows:
Outer braces and leading ! are stripped.
If the result matches "var op value" (where op is
one of <=, <, >=, >, ==,
!=), the comparison is executed directly on
df.predict[[var]].
Otherwise the expression is treated as a column name and
membership is df.predict[[name]] == 1.
Data frame with treatment recommendation flag
(treat.recommend): 0 for harm subgroup, 1 for complement.
evaluate_comparison for the operator-dispatch
logic, forestsearch for the main analysis function.
## Not run:
# With brace-wrapped label expressions
sg <- c("{er <= 0}", "{size <= 35}")
df_out <- get_dfpred(df.predict = test_data, sg.harm = sg)
# With negation
sg_neg <- c("{er <= 0}", "!{size <= 35}")
df_neg <- get_dfpred(df.predict = test_data, sg.harm = sg_neg)
# With bare column names (binary indicators)
sg_col <- c("q1.1", "q3.1")
df_col <- get_dfpred(df.predict = encoded_data, sg.harm = sg_col)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.