# Basic examples of frequency tables (without y variable)
tinyplot(~ cyl, data = mtcars, type = "barplot")
tinyplot(~ cyl | vs, data = mtcars, type = "barplot")
tinyplot(~ cyl | vs, data = mtcars, type = "barplot", beside = TRUE)
tinyplot(~ cyl | vs, data = mtcars, type = "barplot", beside = TRUE, fill = 0.2)
# Note: Above we used automatic argument passing for `beside`. But this
# wouldn't work for `width`, since it would conflict with the top-level
# `tinyplot(..., width = )` argument. It's safer to pass these args
# through the `type_barplot()` functional equivalent.
tinyplot(~ cyl | vs, data = mtcars, fill = 0.2,
type = type_barplot(beside = TRUE, drop.zeros = TRUE, width = 0.65))
tinytheme("clean2")
# Example for numeric y aggregated by x (default: FUN = mean) + facets
tinyplot(extra ~ ID | group, facet = "by", data = sleep,
type = "barplot", fill = 0.6)
# Fancy frequency table:
tinyplot(Freq ~ Sex | Survived, facet = ~ Class, data = as.data.frame(Titanic),
type = "barplot", facet.args = list(nrow = 1), flip = TRUE, fill = 0.6)
# Centered barplot for conditional proportions of hair color (black/brown vs.
# red/blond) given eye color and sex
tinytheme("clean2", palette.qualitative = c("black", "sienna", "indianred", "goldenrod"))
hec = as.data.frame(proportions(HairEyeColor, 2:3))
tinyplot(Freq ~ Eye | Hair, facet = ~ Sex, data = hec, type = "barplot",
center = TRUE, flip = TRUE, facet.args = list(ncol = 1), yaxl = "percent")
tinytheme()
Run the code above in your browser using DataLab