## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(vcdinteractive)
has_vcd <- requireNamespace("vcd", quietly = TRUE)

## ----horse, eval = has_vcd----------------------------------------------------
data(HorseKicks, package = "vcd")
HorseKicks
irootogram(HorseKicks, xlab = "Deaths by horse kicks per corps-year",
           main = "Horse kicks: Poisson", height = 500)

## ----federalist, eval = has_vcd-----------------------------------------------
data(Federalist, package = "vcd")
w <- irootogram(Federalist, dists = c("poisson", "nbinomial"),
                xlab = "Occurrences of 'may' per block", main = "Federalist Papers",
                height = 520)
sapply(w$x$fits, function(f) c(G2 = round(f$G2, 2), df = f$df, p = signif(f$p_G2, 3)))
w

