prep_data_likert: Helper function for 'mk_likertplot'. Not for external use.

View source: R/retired/prep_data_likert.R View source: R/prep_data_likert.R

prep_data_likertR Documentation

Helper function for mk_likertplot. Not for external use.

Description

prep_data_likert takes in the original data frame, the x, y and fillby variable, the supplied levels of the fillby variable, and instruction on how to order the y levels. It returns a list of 2 data frames (df_neg and df_pos), along with some plot elements for making a likert chart, a.k.a., horizontal diverging bar chart.

Usage

prep_data_likert(df, xvar, yvar, fillby, fillby_lvls, rawcnt_var, yorder)

Arguments

df

Data frame of the original data.

xvar

String, name of x numeric variable.

yvar

String, name of y categorical (character or factor) variable.

fillby

String, name of a second categorical variable for sub-dividing and coloring the bars.

fillby_lvls

Character vector, levels of the fillby variable that the fillby variable should be ordered accordingly.

yorder

String, possible values are "alphanumeric", "descend" or "ascend". If "alphanumeric", order y levels in alphanumerical order along y-axis. If "ascend"/"descend", order y levels in ascending/descending order of the sum of absolute x-values along y-axis.

rawcnt_var.

String, name of the variable that contains the raw count behind each tier. Default = NULL because not all input dataframe has such a variable.

Value

A list of 2 data frames (df_neg and df_pos), breaks and labels for the continuous axis, and palette for coloring the bars (pal).

See Also

mk_likertplot.


gmlang/ezplot documentation built on Sept. 18, 2022, 6:33 a.m.