hist_norm {pubh} | R Documentation |
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: |
data |
A data frame where the variables in the |
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
require(dplyr, quietly = TRUE)
require(sjlabelled, quietly = TRUE)
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")
birthwt %>%
hist_norm(~ bwt | smoke, alpha = 0.7, bins = 20, fill = "cadetblue")
[Package pubh version 1.3.2 Index]