mk_percentileplot_convars: Create a function for making publishable ggplot2 percentile...

View source: R/mk_percentileplot_convars.R

mk_percentileplot_convarsR Documentation

Create a function for making publishable ggplot2 percentile plots of one continuous variable against another continuous variable.

Description

mk_percentileplot_convars takes a data frame as input and returns a function for binning a continuous variable from the data frame, and plotting the average values of the bins on the x-axis and the (25th, 50th and 75th) percentiles of another continuous variable grouped by the bins on the y axis. This is a good alternative to scatterplots when the data points overlap.

Usage

mk_percentileplot_convars(df)

Arguments

df

A data frame.

Value

function(xvar, yvar, pt_size = 1, linew = 0.7, xcuts = 15, probs = c(0.75, 0.5, 0.25), legend_title = c('75th', '50th', '25th'), legend_pos = "right", font_size = 14)

  • xvar. String, name of a continuous variable for x-axis.

  • yvar. String, name of a continuous variable for y-axis.

  • pt_size. Number, size of the points. Default = 1.

  • linew. Number, width of the line. Default = 0.7.

  • xcuts. A numeric vector of two or more unique cut points or a single number (greater than or equal to 2) giving the number of intervals into which x is to be cut. Default = 15.

  • probs. Numeric vector. Probabilities for which the percentiles will be calculated and plotted. Default = c(0.75, 0.5, 0.25), and it'll plot the 75th, 50th and 25th percentiles of the y variable at each x value.

  • legend_title. String, legend title. Default = = c('75th', '50th', '25th').

  • legend_pos. String, legend position. Default = "right".

  • font_size. Overall font size. Default = 14. The font size of the axes and legend text is a fraction of this value.

Examples

inst/examples/ex-mk_percentileplot_convars.R

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