prep_data_dumbbell: Helper function for 'mk_dumbbell'. Not for external use.

View source: R/prep_data_dumbbell.R

prep_data_dumbbellR Documentation

Helper function for mk_dumbbell. Not for external use.

Description

prep_data_dumbbell takes in the original data frame, the left and right end point x variables, the y variable, and the instruction on how to order the y levels. It returns a data frame with y ordered according to the supplied instruction, and a new column called diff (difference between the right and left end point xvars) appended.

Usage

prep_data_dumbbell(df, xvar_left, xvar_right, yvar, yorder)

Arguments

df

Data frame of the original data.

xvar_left

String, name of a numeric variable, left end-point on x.

xvar_right

String, name of a numeric variable, right end-point on x.

yvar

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

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 difference between xvar_right and xvar_left.

Value

The original data frame with y ordered according to instruction and a new column called diff appended.

See Also

mk_dumbbell.


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