split_dataline.RdThis function takes a scplot object and adds treatment datalines according to the specified variables.
split_dataline(
object,
tvar,
dvar = NULL,
levels = NULL,
labels = NULL,
remove_original = TRUE,
color = NULL,
...
)A scplot object containing the scdf data.
The treatment variable.
The dependent variable which provides the values for the new datalines. If NULL, the default dependent variable of the scplot object is used.
Optional, a vector of treatment levels.
Optional, labels for the treatment levels.
Logical, should the original dependent variable be removed from the cases where the treatment variable matches the level? (default is FALSE).
Optional, a vector of colors for the new datalines. If provided, the length of the color vector should match the number of treatment levels. If not provided, default colors will be used for the datalines.
Additional arguments.
The modified scplot object with added datalines.
The function identifies unique treatment levels from the specified treatment variable and creates new datalines for each level. The new datalines are added to the scplot object, and the original dependent variable can optionally be removed from cases where the treatment variable matches the level.
scplot(scan::example_atd) |>
split_dataline("treatment")