[Rd] extendrange(): suggested improvement
Marius Hofert
marius.hofert at uwaterloo.ca
Wed Apr 25 23:31:01 CEST 2018
Hi,
I often need to extend the plot range to the right, but not to the
left (for example: not below 0 so that log = "x" still works...). This
could be a handy improvement of extendrange():
--- utils.R 2015-08-25 18:18:20.000000000 -0400
+++ utils.R 2018-04-25 17:21:25.000000000 -0400
@@ -30,6 +30,6 @@
## Purpose: extend a range by a factor 'f' - on each side
if(!missing(r) && length(r) != 2)
stop("'r' must be a \"range\", hence of length 2")
- r + c(-f,f) * diff(r)
-
+ if(length(f) == 1) f <- rep(f, 2)
+ r + c(-f[1], f[2]) * diff(r)
}
Cheers,
M
More information about the R-devel
mailing list