HH (version 2.2-17)

intxplot: Interaction plot, with an option to print standard error bars.

Description

Interaction plot, with an option to print standard error bars. There is an option to offset group lines to prevent the bars from overprinting.

Usage

intxplot(x, data=sys.parent[1], groups.in,
          scales,
          key.length=1,
          key.lines,
          key=TRUE,
          trace.factor.name=deparse(substitute(groups.in)),
          x.factor.name=x.factor,
          xlab=x.factor.name,
          main=list(main.title, cex=main.cex),
          condition.name="condition",
          panel="panel.intxplot",
          summary.function="sufficient",
          se,
          ...,
          data.is.summary=FALSE,
          main.title=paste(
            "Interactions of", trace.factor.name, "and",
            x.factor.name,
            if (length(x[[3]]) > 1)
            paste("|", condition.name.to.use)),
          main.cex=1.5)

panel.intxplot(x, y, subscripts, groups, type = "l", ..., se, cv=1.96,
               offset.use=(!missing(groups) && !missing(se)),
               offset.scale=2*max(as.numeric.positioned(groups)),
               offset=
               as.numeric.positioned(groups[match(levels(groups),
                                            groups)]) / offset.scale,
               rug.use=offset.use)

Arguments

Value

"trellis" object.

See Also

sufficient

Examples

Run this code
## This uses the same data as the HH Section 12.13 rhizobium example.

rhiz.clover <- read.table(hh("datasets/rhiz3-clover.dat"), header=TRUE)
rhiz.clover$comb <- factor(rhiz.clover$comb,
                         labels=c("clover","clover+alfalfa"))
position(rhiz.clover$comb) <- c(2,5)
rhiz.clover$strain <-
  factor(rhiz.clover$strain,
         labels=c('3DOk1','3DOk5','3DOk4','3DOk7','3DOk13','k.comp'))
rhiz.clover$Npg <- rhiz.clover$nitro / rhiz.clover$weight

## interaction plot, no se
intxplot(Npg ~ strain, groups=comb, data=rhiz.clover)

## interaction plot, individual se for each treatment combination
intxplot(Npg ~ strain, groups=comb, data=rhiz.clover, se=TRUE)

## Rescaled to allow the CI bars to stay within the plot region
intxplot(Npg ~ strain, groups=comb, data=rhiz.clover, se=TRUE,
         ylim=range(rhiz.clover$Npg))

## interaction plot, common se based on ANOVA table
intxplot(Npg ~ strain, groups=comb, data=rhiz.clover,
         se=sqrt(sum((nobs-1)*sd^2)/(sum(nobs-1)))/sqrt(5))

## Rescaled to allow the CI bars to stay within the plot region
intxplot(Npg ~ strain, groups=comb, data=rhiz.clover,
         se=sqrt(sum((nobs-1)*sd^2)/(sum(nobs-1)))/sqrt(5),
         ylim=range(rhiz.clover$Npg))

## change distance between endpoints
intxplot(Npg ~ strain, groups=comb, data=rhiz.clover,
         se=TRUE, offset.scale=20)

## When data includes the nobs and sd variables, data.is.summary=TRUE is needed.
intxplot(Npg ~ strain, groups=comb,
         se=sqrt(sum((nobs-1)*sd^2)/(sum(nobs-1)))/sqrt(5),
         data=sufficient(rhiz.clover, y="Npg", c("strain","comb")),
         data.is.summary=TRUE,
         ylim=range(rhiz.clover$Npg))

Run the code above in your browser using DataCamp Workspace