[R] Debugging R's code: boxplot.stats

Matthew Walker m.g.walker at massey.ac.nz
Mon Oct 30 07:32:25 CET 2006


On Sun, 2006-10-29 at 20:18 -0500, Duncan Murdoch wrote:
> If you're sure your change is a good idea then post a patch here along 
> with an explanation of why it's so good:  and it might make it into the 
> next release.

Thank you to both Duncan and Gabor, your help was really appreciated.

My 10 character alteration did what I hoped it would.  So I'd like to
offer it to you or whoever else might be interested.

Boxplot does it's job well, it even mostly "works" with infinite values
by not plotting certain lines.  For example, if the upper bound is
infinite, the upper whisker isn't plotted.  

However boxplot doesn't work if the upper bound, upper quartile, median,
and lower quartile are all infinite.  Although there is sufficient data
to plot a lower bound, boxplot.stats errors instead.  This error also
occurs when the lower bound through to the upper quartile are negative
infinity.

This is not tricky to fix.  All that needs to change is line 14 of
boxplot.stats.  It currently reads:
"if (any(out[nna]))"
Changing it to:
"if (any(out[nna],na.rm=TRUE))"
fixes these issues.

Cheers,

Matthew



More information about the R-help mailing list