[Rd] segments() with zero-length arguments (PR#11192)
ripley at stats.ox.ac.uk
ripley at stats.ox.ac.uk
Thu Apr 17 11:45:37 CEST 2008
I think we should allow only all-zero arguments (at present any
zero-length argument is an error), as per the R-level proposed code.
arrows() and rect() share the code so it is much cleaner to do this
internally.
Done for R-devel.
On Thu, 17 Apr 2008, rmh at temple.edu wrote:
> Uwe Ligges suggested I post this on R-bugs as a wishlist item with a
> proposed patch. R considers zero-length arguments to segments() to be
> an error. I would like R to allow this and to return without an
> error. It occurs naturally in settings like
>
> valid <- c(FALSE, FALSE, FALSE)
> segments(x0[valid], y0[valid], x1[valid], y1[valid])
>
> For what it may be worth, S-Plus does not consider zero-length
> arguments to segments() be an error.
>
>
> plot(1:10)
> segments(1,1,10,10,col='green')
> segments(numeric(0), numeric(0), numeric(0), numeric(0), col='green')
> Error in segments(x0, y0, x1, y1, col = col, lty = lty, lwd = lwd, ...) :
> invalid first argument
>
>
> segments.proposal <-
> function (x0, y0, x1, y1, col = par("fg"), lty = par("lty"),
> lwd = par("lwd"), ...) {
> if (length(x0)==0 && length(y0)==0 && length(x1)==0 && length(y1)==0)
> return(invisible(NULL))
> .Internal(segments(x0, y0, x1, y1, col = col, lty = lty, lwd = lwd, ...))
> }
>
> segments.proposal(numeric(0), numeric(0), numeric(0), numeric(0), col='green')
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list