Learn R Programming

metricsgraphics (version 0.9.0)

mjs_histogram: Plot Histograms with MetrisGraphics

Description

Given a numeric vector or a data frame and numeric column name (bare or quoted), plot a histogram with the specified parameter. This function automatically a y axis label "Frequency" which you can override with a call to mjs_labs.

Usage

mjs_histogram(mjs, bar_margin = 1, bins = NULL)

Arguments

mjs
metricsgraphics plot object
bar_margin
space between bars (defaults to 1)
bins
numbenr of bins for the histogram (NULL == let MetricsGraphcis.js library compute)

Value

metricsgraphics plot object

Examples

Run this code
movies <- ggplot2movies::movies[sample(nrow(ggplot2movies::movies), 1000), ]

mjs_plot(movies$rating) %>% mjs_histogram()

mjs_plot(movies, rating) %>%
  mjs_histogram() %>%
  mjs_labs(x_label="Histogram of movie ratings")

mjs_plot(movies$rating) %>%
  mjs_histogram(bins=30)

mjs_plot(runif(10000)) %>%
  mjs_histogram() %>%
  mjs_labs(x_label="runif(10000)")

Run the code above in your browser using DataLab