Given a dataframe with the variable of interest and a vector of lower and upper percentiles, the function creates two new columns called low and high corresponding to the quantiles of interest.

create_df_marginal_comparisons(dat, var, percentiles, by_var)

Arguments

dat

A dataframe containing the variables of interest. A dataframe.

var

The name of the variable of interest. A string.

percentiles

A vector with two elements corresponding to the lower and upper percentiles. A vector.

by_var

The variable name to group by. A string.

Value

A dataframe with two new columns, low and high, to be used for marginal comparisons.