View source: R/retired/prep_data_likert.R View source: R/prep_data_likert.R
prep_data_likert | R Documentation |
mk_likertplot
. Not for external use.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.
prep_data_likert(df, xvar, yvar, fillby, fillby_lvls, rawcnt_var, yorder)
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. |
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).
mk_likertplot
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.