View source: R/plot_functions.R
hist_norm | R Documentation |
hist_norm
constructs histograms and adds corresponding Normal density curve.
hist_norm(
object = NULL,
formula = NULL,
data = NULL,
bins = 20,
fill = "indianred3",
color = "black",
alpha = 0.4,
...
)
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 |
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.