Skip to contents

An opinionated function that delivers single varible descriptive graphs based on the variable's class.

Usage

visualize_sngl_var(
  df,
  var,
  xlab,
  ylab = NULL,
  theme = NULL,
  widget = FALSE,
  flip = FALSE,
  cutoff = 30,
  ...
)

Arguments

df

A data frame from which a variable will be visualized.

var

A character representing the name of a single variable of a given data frame.

xlab

An required character value representing the label that will be placed on the x-axis. You may be asking, why do I need to provide this when the variable named is also required. Simply, so that the user can explicitly decide how the variable label will be printed for users.

ylab

An optional character representing the label that will be placed on the y-axis.

theme

A ggplot theme used to tweak the display of the graph.

widget

A boolean which defaults to FALSE. When TRUE, the graph is returned as an interactive HTML widget powered by the plotly library.

flip

A boolean which defaults to FALSE. When TRUE, the graph is turned on its axis.

cutoff

A numeric value used to select the number of variables that will be graphed when working with categorical data. This value is intended to limit the amount of bars plotted and make graphs more legible. Defaults to a value of 30.

...

Other arguments passed on to the geom, labs, ggplotly, or plotly config functions.

Examples

if (FALSE) {
d <- data.frame(
  "char" = rep(LETTERS[1:5], 10),
  "ints" = rep(c(1L, 2L), 25)
 )
 
visualize_sngl_var(d, "ints", widget = TRUE, xlab = "Integers",
   ylab ="Count")
}