[R] Error message when using error.bars(x,add=TRUE)

Peter Ehlers ehlers at ucalgary.ca
Fri Feb 19 12:24:42 CET 2010


On 2010-02-18 8:22, fussel wrote:
>
> Hey hey,
> I`m analyzing a data set containing the element contentrations of various
> samples...
> I wanted to construct notched boxplots and got quite ugly results for some
> of the boxplots. The notches are often larger then the hinges which resulted
> in weird looking edges (even though I`m using a log-boxplot). To avoid this
> problem I thought about using "normal" log-boxplots and adding some kind of
> parantheses for showing the confidence interval.
> I found an option to do this with the help of the package "psych".
>
> It works beautifully for sth like that:
> x<- replicate(20,rnorm(50))
> boxplot(x,notch=TRUE,main="Notched boxplot with error bars")
> error.bars(x,add=TRUE)
> abline(h=0)

Beautifully? To me, that's one of the ugliest plots I've seen
in a while. But, as they say, it's in the eye of the beholder.

Anyway, what is the purpose of the notches? It's not clear
to me that you understand them. There's a good reason why the
notches sometimes stick out beyond the box. This is usually
the result of a small sample. If you have variable sample sizes
you might find variable-width boxplots somewhat informative.
Personally, I don't have much for use notched boxplots.


> I tried to apply this to my own dataset:
>
> ## Ag
> boxplotDAS(log10(Ag)~Aquifer,ylab="",xlab="Ag (mg/l)", main="",
> data=samples, notch=TRUE, horizontal=TRUE, xaxt="n", col="gray85")
> error.bars(samples,add=TRUE)
> axis(1,at=log10(a<-sort(c((10^(-50:50))%*%t(c(1,5))))),labels=a, tick=T)
> abline(v=log10(a),lty=3,col='gray')
>
>
> I end up with lots of error messages - all of them saying:
>
> Warning in arrows(s[s], x.stats$mean[s] - ci[s] * x.stats$se[s], s[s],
> x.stats$mean[s] +  :
>    zero-length arrow is of indeterminate angle and so skipped
>
> What does that mean and how can I get rid of it? Any ideas?

These warning (not 'error') messages come from error.bars().
Why not try to plot the error bars without any boxplots to see
where the problems might lie. As a check, I would also do the
confidence interval calculations 'by hand'.

Or you could provide a *reproducible* example, preferably
minimal (i.e. skip the xlab= , etc stuff) and someone might
try the code and tell you where the problems lie.

  -Peter Ehlers
>
> Thanks a lot,
> fussel
>



More information about the R-help mailing list