rmh at temple.edu
2008-Apr-16 22:30 UTC
[Rd] segments() with zero-length arguments (PR#11192)
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')
ripley at stats.ox.ac.uk
2008-Apr-17 09:45 UTC
[Rd] segments() with zero-length arguments (PR#11192)
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
Maybe Matching Threads
- Request - adding recycled "lwd" parameter to polygon
- Request - adding recycled "lwd" parameter to polygon
- documenation for arrows() is backwards (PR#7839)
- suggest enhancement to segments and arrows to facilitate horizontal and vertical segments
- Drawing dendrogram