histogram_from_hist {kim}R Documentation

Histogram from hist function

Description

Create a histogram based on the output of the hist function in the graphics package.

Usage

histogram_from_hist(
  vector = NULL,
  breaks = NULL,
  counts = NULL,
  percent = FALSE,
  bin_fill_color = "green4",
  bin_border_color = "black",
  bin_border_thickness = 1,
  notify_na_count = NULL,
  x_axis_tick_marks = NULL,
  y_axis_tick_marks = NULL,
  cap_axis_lines = TRUE,
  x_axis_title = "Value",
  y_axis_title = NULL,
  y_axis_title_vjust = 0.85
)

Arguments

vector

a numeric vector

breaks

a numeric vector indicating breaks for the bins. By default, no input is required for this argument.

counts

a numeric vector containing counts for the bins (i.e., heights of the bins). By default, no input is required for this argument.

percent

logical. If percent = TRUE, percentages will be plotted rather than frequencies (default = FALSE).

bin_fill_color

color of the area inside each bin (default = "green4")

bin_border_color

color of the border around each bin (default = "black")

bin_border_thickness

thickness of the border around each bin (default = 1)

notify_na_count

if TRUE, notify how many observations were removed due to missing values. By default, NA count will be printed only if there are any NA values.

x_axis_tick_marks

a vector of values at which to place tick marks on the x axis (e.g., setting x_axis_tick_marks = seq(0, 10, 5) will put tick marks at 0, 5, and 10.)

y_axis_tick_marks

a vector of values at which to place tick marks on the y axis (e.g., setting y_axis_tick_marks = seq(0, 10, 5) will put tick marks at 0, 5, and 10.)

cap_axis_lines

logical. Should the axis lines be capped at the outer tick marks? (default = FALSE)

x_axis_title

title for x axis (default = "Value")

y_axis_title

title for y axis (default = "Count" or "Percentage", depending on the value of percent)

y_axis_title_vjust

position of the y axis title (default = 0.85).

Value

the output will be a histogram, a ggplot object.

Examples


histogram_from_hist(1:100)
histogram_from_hist(c(1:100, NA))
histogram_from_hist(vector = mtcars[["mpg"]])
histogram_from_hist(vector = mtcars[["mpg"]], percent = TRUE)
histogram_from_hist(vector = mtcars[["mpg"]],
x_axis_tick_marks = c(10, 25, 35), y_axis_title_vjust = 0.5,
y_axis_title = "Freq", x_axis_title = "Values of mpg")


[Package kim version 0.5.422 Index]