pubh (version 1.1.16)

hist_norm: Histogram with Normal density curve.

Description

hist_norm constructs histograms and adds corresponding Normal density curve.

Usage

hist_norm(
  object = NULL,
  formula = NULL,
  data = NULL,
  bins = 20,
  fill = "indianred3",
  color = "black",
  alpha = 0.4,
  ...
)

Arguments

object

When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument. See details and examples.

formula

A formula with shape: ~ y or ~ y|x where y is a numerical variable and x is a factor.

data

A data frame where the variables in the formula can be found.

bins

Number of bins of the histogram.

fill

Colour to fill the bars of the histogram.

color

Colour used for the border of the bars.

alpha

Opacity (0 = invisible, 1 = opaque).

...

Further arguments passed to gf_dhistogram.

Examples

Run this code
# NOT RUN {
require(dplyr)
require(sjlabelled)
data(birthwt, package = "MASS")
birthwt <- birthwt %>%
  mutate(
    smoke = factor(smoke, labels = c("Non-smoker", "Smoker")),
    Race = factor(race > 1, labels = c("White", "Non-white"))
  ) %>%
  var_labels(
    bwt = 'Birth weight (g)',
    smoke = 'Smoking status'
 )

birthwt %>%
  hist_norm(~ bwt, alpha = 0.7, bins = 20, fill = 'cadetblue') %>%
  axis_labs()

birthwt %>%
  hist_norm(~ bwt|smoke, alpha = 0.7, bins = 20, fill = 'cadetblue') %>%
  axis_labs()
# }

Run the code above in your browser using DataLab