Create Ordered Variable Based on Quantile Breaks
create_ordered_variable.Rd
This function takes a data frame and a specified variable name and divides the variable into ordered categories based on quantile breaks. The number of quantile divisions must be specified. The function is designed to handle non-unique breaks by adjusting them appropriately. It returns the data frame with a new ordered factor variable.
Arguments
- df
A data frame containing the variable to be divided into quantiles.
- var_name
The name of the variable within the data frame to divide into quantiles. For example, in the `df_nz` dataset, you might use "perfectionism".
- n_divisions
The number of quantile divisions to create. This must be a positive integer. If NULL or not specified, the function will stop and ask the user to provide this parameter.