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")
Run the code above in your browser using DataLab