From marius.hofert at uwaterloo.ca  Wed Apr 25 23:31:01 2018
From: marius.hofert at uwaterloo.ca (Marius Hofert)
Date: Wed, 25 Apr 2018 17:31:01 -0400
Subject: [Rd] extendrange(): suggested improvement
Message-ID: <CAM3-KjZpx8dXZBOvzY5iipny1WHVZ+S4wmG8tTYFMaj2Rn973A@mail.gmail.com>

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



[Rd] extendrange(): suggested improvement
Marius Hofert