Learn R Programming

creditmodel (version 1.3.0)

plot_bar: Plot Bar

Description

You can use the plot_bar to produce the barplot.

Usage

plot_bar(
  dat,
  x,
  y = NULL,
  x_breaks = NULL,
  y_breaks = NULL,
  cut_bin = "equal_width",
  g_x = 10,
  g_y = 5,
  string_bins = FALSE,
  target = NULL,
  value = NULL,
  type = "total_pct",
  reverse = FALSE,
  position = "dodge",
  dodge_width = 0.9,
  pl_theme = plot_theme(legend.position = "top", title_size = 9, legend_size = 7,
    axis_title_size = 8),
  fill_colors = c(love_color(type = "deep"), love_color(type = "light"),
    love_color(type = "shallow"))
)

Arguments

dat

A data.frame with independent variables and target variable.

x

The name of an independent variable.

y

The name of target variable. Default is NULL.

x_breaks

Breaks points of x.

y_breaks

Breaks points of y.

cut_bin

'equal_width' or 'equal_depth' to produce the breaks points.

g_x

Number of initial breakpoints for equal frequency binning of x.

g_y

Number of initial breakpoints for equal frequency binning of y.

string_bins

Whether to process bins of classification variables.

target

The name of target variable.

value

The name of the variable to sum. When this parameter is NULL, the default statistics is to sum frequency.

type

Output form of the result of crosstable. Provide these forms:"each_pct_x", "each_pct_y","total_sum","total_pct","total_mean","total_median","total_max","total_min","bad_sum","bad_pct".

reverse

Logical,whether reverse the plot.

position

Postion of bars, 'stack' or 'dodge' is available.

dodge_width

Width of width.

pl_theme

Theme of the plot

fill_colors

Colors of bar.

Examples

Run this code
# NOT RUN {
plot_bar(dat = lendingclub, x = "grade")
plot_bar(dat = lendingclub, x = "grade", y= "dti", 
         g_x = 5,g_y = 3,
		 position = 'dodge', dodge_width = 0.9,
		 type = "each_pct_x",
		 reverse = FALSE,
		 cut_bin = 'equal_depth',
 fill_colors = c(love_color(type = "line"),
  love_color(type = "line")))
# }

Run the code above in your browser using DataLab