[R] Problem with bargraph.CI in Sciplot package
Manuel Morales
Manuel.A.Morales at williams.edu
Wed Apr 15 03:00:16 CEST 2009
On Sat, 2009-04-11 at 08:10 -0400, Manuel Morales wrote:
> On Fri, 2009-04-10 at 15:07 -0700, Metconnection wrote:
> > Hi there,
> > I wonder if anyone can help me. I'm trying to use bargraph.CI in the Sciplot
> > package when there is a missing combination of the factor levels.
> > Unfortunately the standard errors on the plot do not appear to be correct.
> >
> > Consider an analysis consisting of two factors A and B. When all factor
> > level combinations are present all appears fine:
> >
> > library(sciplot)
> >
> > #all data
> > response<-c(32,54,32,65,34,65,65,45,54,23,43,23,76,87,65,45)
> > factorA<-c("A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B")
> > factorB<-c("a","a","a","a","b","b","b","b","a","a","a","a","b","b","b","b")
> > data<-data.frame(response,factorA,factorB)
> > bargraph.CI(x.factor = data$factorB,data$response, group=data$factorA,
> > legend=TRUE)
> >
> >
> >
> > but when I remove a combination of the two factors the error whiskers appear
> > to be on the wrong bars:
> >
> >
> > #excluding one combination
> > response<-c(34,65,65,45,54,23,43,23,76,87,65,45)
> > factorA<-c("A","A","A","A","B","B","B","B","B","B","B","B")
> > factorB<-c("b","b","b","b","a","a","a","a","b","b","b","b")
> > data<-data.frame(response,factorA,factorB)
> > bargraph.CI(x.factor = data$factorB,data$response, group=data$factorA,
> > legend=TRUE)
> >
> >
> > I had a look at the ci.fun options but with no success.
> >
> > Thanks in advance for any ideas
> > Simon
>
> Hi Simon,
>
> bargraph.CI was intended for factorial designs and it doesn't work well
> with missing factor combinations. I'll take a look at changing this, but
> for now, a quick fix is to add the missing combination with an NA value
> for the response. Eg., change the data in your second example to:
>
> response<-c(34,65,65,45,54,23,43,23,76,87,65,45,NA)
> factorA<-c("A","A","A","A","B","B","B","B","B","B","B","B","A")
> factorB<-c("b","b","b","b","a","a","a","a","b","b","b","b","a")
This issue has been fixed in version 1.0-5 which I just uploaded to
CRAN. It should be available to download soon.
More information about the R-help
mailing list