asherman at ksu.ru
2008-Nov-27 13:30 UTC
[Rd] A small bug in R code of the legend function of the Graphics pacakge (PR#13340)
Full_Name: Arkady Sherman Version: 2.8.0 OS: Windows XP Submission from: (NULL) (158.195.16.114) Please consider initialization of the "seg.len" variable. It's done only if (do.lines) { seg.len <- 2 .., but after the seg.len is used: if (has.pch) { pch <- rep(pch, length.out = n.leg) pt.bg <- rep(pt.bg, length.out = n.leg) pt.cex <- rep(pt.cex, length.out = n.leg) pt.lwd <- rep(pt.lwd, length.out = n.leg) ok <- !is.na(pch) & (is.character(pch) | pch >= 0) x1 <- (if (merge) xt - (seg.len/2) * xchar so if do.lines isn't specified, but has.pch and merge are specified an error is produced. Guess that seg.len should be initialized before the condition "if (do.lines)" Thanks in advance.
maechler at stat.math.ethz.ch
2008-Nov-29 17:10 UTC
[Rd] A small bug in R code of the legend function of the Graphics pacakge (PR#13340)
>>>>> "ASh" == asherman <asherman at ksu.ru> >>>>> on Thu, 27 Nov 2008 14:30:04 +0100 (CET) writes:ASh> Full_Name: Arkady Sherman ASh> Version: 2.8.0 ASh> OS: Windows XP ASh> Submission from: (NULL) (158.195.16.114) ASh> Please consider initialization of the "seg.len" ASh> variable. It's done only ASh> if (do.lines) { seg.len <- 2 .., ASh> but after the seg.len is used: ASh> if (has.pch) { ASh> pch <- rep(pch, length.out = n.leg) ASh> pt.bg <- rep(pt.bg, length.out = n.leg) ASh> pt.cex <- rep(pt.cex, length.out = n.leg) ASh> pt.lwd <- rep(pt.lwd, length.out = n.leg) ASh> ok <- !is.na(pch) & (is.character(pch) | pch >= 0) ASh> x1 <- (if (merge) ASh> xt - (seg.len/2) * xchar ASh> so if do.lines isn't specified, but has.pch and merge are specified an error is ASh> produced. but do.lines is never specified. It can be FALSE (if there are no lines drawn) and a user can indeed set 'merge = TRUE" in such a situation. However, can you think of a situation where this was desirable? I think it should not have any effect in such a case {... but unfortunately it currently has ... yet another sign that legend() is ``hopelessly over-featured'' ;-) } and possibly rather give a warning in such a case... ASh> Guess that seg.len should be initialized before the condition "if (do.lines)" not really; it means 'segment length' should not be used unless segments ("lines") are drawn. Thank you for your note; you are right that legend() is not entirely correct in such a border-line situation. Regards, Martin Maechler, ETH Zurich