This function allows non overlapping error bars in latticeExtra::segplot(). It has the groups = argument.

panel.groups.segplot(x, y, z, centers, groups, gap = NULL, data,
  subscripts, ...)

Arguments

x, y, z, centers, data, subscripts, ...

Arguments passed to segplot().

groups

The grouping variable (factor), with the same length of lwr e upr.

gap

Scalar that is the distance among segments. Default is 0.1. If the grouping factor has \(k\) levels, so \(0 \leq \textrm{gap} < 1/k\). A negative value for gap will put the segments in a reversed order.

See also

Examples

library(latticeExtra) m0 <- lm(log(breaks) ~ wool * tension, data = warpbreaks) pred <- with(warpbreaks, expand.grid(KEEP.OUT.ATTRS = TRUE, wool = levels(wool), tension = levels(tension))) pred <- cbind(pred, predict(m0, newdata = pred, interval = "confidence")) str(pred)
#> 'data.frame': 6 obs. of 5 variables: #> $ wool : Factor w/ 2 levels "A","B": 1 2 1 2 1 2 #> $ tension: Factor w/ 3 levels "L","M","H": 1 1 2 2 3 3 #> $ fit : num 3.72 3.28 3.12 3.31 3.12 ... #> $ lwr : num 3.47 3.03 2.87 3.06 2.87 ... #> $ upr : num 3.97 3.53 3.37 3.56 3.37 ...
segplot(wool ~ lwr + upr, centers = fit, data = pred, draw = FALSE, horizontal = FALSE)
segplot(wool ~ lwr + upr, centers = fit, data = pred, draw = FALSE, horizontal = FALSE, groups = tension, gap = 0.05, panel = panel.groups.segplot)