a +1 shift overlaying lines/points on a boxplot (PR#398)
Peter Dalgaard BSA
p.dalgaard@biostat.ku.dk
12 Jan 2000 19:02:51 +0100
acuster@nature.berkeley.edu writes:
> Full_Name: Adrian Custer
> Version: 0.90.0
> OS: Linux on Thinkpad (pentium) and desktop (K6)
> Submission from: (NULL) (128.32.251.234)
>
>
> When I create a boxplot, and then try to overlay a lowess fit or just the
> points,
> the points do not appear in the highest level and the lowess curve does not
> reach
> the highest level. However, if I add one to each of the models, the problem is
> solved.
> I tried this on two different machines, a laptop and a desktop both running
> Gnu/linux+gnome. If you can't reproduce this please let me know. -adrian
>
> > a
> [1] 0.629 -0.584 0.132 -0.012 -0.813 -0.291 -0.813 -0.291 -0.584 -0.164
...
> [291] 0.505 0.254 -0.188 -0.306 0.387 0.099 0.012 0.659 0.179 0.099
> > b
> [1] 4 0 0 3 0 3 4 4 4 0 4 0 4 2 0 4 0 0 4 0 2 3 1 3 3 4 4 3 3 4 4 4 2 3 3 0 3
> [38] 0 4 3 3 2 4 3 3 4 4 1 0 0 4 0 0 3 0 3 4 4 4 0 4 0 4 2 0 4 0 0 4 0 2 3 1 3
.....
> [297] 4 1 0 0
> > boxplot(a~b)
> > lines(lowess(a~b))
> > points(a~b)
> > boxplot(a~b)
> > lines(lowess(a~b+1))
> > points(a~b+1)
> >
>
> Thanks for your consideration and thanks a million for all the work. R is a
> pleasure
> to work with.
Boxplot expects a *factor* as the grouping criterion. The x axis
labels are the group names, not x coordinates (i.e. it might as well
be "married, unmarried, divorced" as "0, 1, 2."), and since factors
are internally coded as 1:nlevels, that's the value used for the
actual coordinate system.
Passing a numeric vector gets it converted to a factor before use, so
things are as you should expect. Except possibly for two issues:
a) should one really do the numeric->factor conversion without a
warning message?
b) perhaps boxplot could use an at= argument saying "plot boxes here"
since the current version wouldn't be able to deal with
non-equidistant groups.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._