Some standard data preparation for plotting
plot_data_prep.Rd
Handles common data preparation for plotting. One of the goals here is to avoid making a million very similar datasets- doing it in functions keeps those changes sandboxed and allows consistent error checking and formatting.
Usage
plot_data_prep(
data,
outcome_col,
sceneorder = NULL,
base_list = NULL,
zero_adjust = 0,
onlyzeros = FALSE
)
Arguments
- data
dataframe to prep
- outcome_col
character, column name for outcome variable.
- sceneorder
character or factor giving the order to present scenario levels. Default NULL uses default ordering.
- base_list
NULL (default) or list of arguments for
baseline_compare()
- zero_adjust
numeric (default 0) or
"auto"
, adjustment to data to avoid zeros by addingzero_adjust
toabs(data)
, e.g shifting all data away from zero, either positively or negatively. Zeros themselves are shifted up or down randomly. Used for avoiding x/0, NaN, and Inf when relativiszing and taking logs, primarily. Auto shifts by0.1*min(abs(data[data != 0]))
. note the adjustment happens before baselining (so the baselining works), but if the baseline reintroduces zeros, they will not be re-adjusted out. This is done under the expectation that zeros returned by baselining are desired, e.g. difference of a baseline with itself.- onlyzeros
logical, default
FALSE
. Should all values be adjusted away from zero (TRUE
) or only adjust zero values (FALSE
)?