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 |>
bar_error(bwt ~ smoke, fill = "plum3")
birthwt |>
bar_error(bwt ~ smoke | Race, fill = "plum3")
birthwt |>
bar_error(bwt ~ smoke, fill = ~Race)
Run the code above in your browser using DataLab