R-alpha: bug report and patch for rep(.)

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Fri, 30 May 97 18:24:15 +0200


rep(1,0) gives	'Error: subscript out of bounds'

Here is the new  ../src/library/base/funs/rep	
		    -------------------------
(which contains two patches, the first of which I posted on May 20):

rep <- function(x, times, length.out)
{
	if (length(x) == 0)
		return(x)
	if (missing(times))
		times <- ceiling(length.out/length(x))
	r <- .Internal(rep(x,times))
	if(!is.null(nm <- names(x))) names(r) <- .Internal(rep(nm, times))
	if (!missing(length.out))
		return(r[if(length.out>0) 1:length.out else integer(0)])
	return(r)
}

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-