Skip to contents

customDataGen() takes in an R data frame and processes it to generate data suitable for the drawr() function.

Usage

customDataGen(
  df,
  xvar = NULL,
  yvar = NULL,
  regression_type = "linear",
  success_level = NULL,
  degree = NULL,
  span = 0.75,
  log_y = F,
  log_base = NULL,
  conf_int = F
)

Arguments

df

An R data frame containing the input data.

xvar

The name of the x variable as a string. If null is provided will use first column of dataframe (default: NULL)

yvar

The name of the y variable as a string. If null is provided will use second column of dataframe. (default: NULL)

regression_type

Type of regression data to generate. Options include "linear", "polynomial", "logistic" (only for binary logistic regression), or "loess". (Default: "linear")

success_level

Which level of binary categorical variable should be considered success if using "logistic" regression. If NULL uses alphabetical order. (Default: NULL)

degree

The degree for a polynomial or loess regression. If chosen in regression_type. For loess 'degree' must be 0, 1 or 2. (Default: 2 for polynomial, 1 for loess)

span

The span for a loess regression. (Default: 0.75)

log_y

Specify whether to apply a logarithmic transformation to y for the fitted line for when using a non-linear scale in the drawr() function. Currently only for linear regression. If TRUE, the fitted line is transformed as log(y) ~ x; if FALSE, the fitted line is not transformed. (default: FALSE)

log_base

Log base for log transformation, only applies if log_y is true. If NULL will apply a natural log transformation. Log_base should match log_base choice in drawr() function. (default: NULL)

conf_int

If a 95% confidence interval should be generated for drawr() function. Currently only for linear regression. (default: FALSE)

Value

A list containing the point data and line data (with equation info) processed from inputted data frame.