biv_bar_plot: A function to display or save density plots created on all...

View source: R/biv_bar_plot.R

biv_bar_plotR Documentation

A function to display or save density plots created on all categorical features.

Description

Creates (or saves as png if asked) bar plots for all density features. Organize the bar plots based on target feature categories and desired barplot types of: dodge, stack, fill.

Usage

biv_bar_plot(
  dataset,
  classVar,
  order = NULL,
  colors = NULL,
  barType = "dodge",
  facet = NULL,
  loc = NULL
)

Arguments

dataset

Name of the data frame object

classVar

Name of the target feature

order

A vector listing the target feature labels in the desired order. To use default order leave this parameter. Default value NULL.

colors

A vector listing which color to use to represent which target feature label. To have the function pick color leave this parameter. Default value NULL.

barType

A string value indicating bar plot type i.e. stack, dodge, fill.

facet

Name of the features along which to separate the plots as facets

loc

A string with the directory where you want to save the plots. If no location is provided the plots will be created and displayed but not stored as image files.

Value

Returns three outputs: 1. If loc = NULL, returns plots and displays in the RStudio Plots window, 2. If loc has location provided, creates and saves the plots. Doesn't display in RStudio.

Examples

library(dplyr)
library(ggplot2)
biv_bar_plot(dataset = iris %>%
mutate(
sepal_width_cat = ifelse(Sepal.Width < mean(iris$Sepal.Width), 'Low', 'High'),
sepal_length_cat = ifelse(Sepal.Length < mean(iris$Sepal.Length), 'Low', 'High')),
classVar = Species, barType = 'fill', facet = sepal_width_cat)


Curious-Joe/fastEda documentation built on March 23, 2022, 12:13 p.m.