|
3 | 3 | #' |
4 | 4 | #' Utilities for sequences, vectors, ranges of values |
5 | 5 | #' |
6 | | -#' $Revision: 1.26 $ $Date: 2026/01/21 06:26:39 $ |
| 6 | +#' $Revision: 1.27 $ $Date: 2026/04/29 06:58:44 $ |
7 | 7 | #' |
8 | 8 | #' ==>> ORIGINAL FILE is in spatstat/develop/Spatstat/R <<== |
9 | 9 |
|
@@ -220,15 +220,21 @@ startinrange <- function(x0, dx, r) { |
220 | 220 | return(y) |
221 | 221 | } |
222 | 222 |
|
223 | | -prettyinside <- function(x, ...) { |
| 223 | +prettyinside <- function(x, ..., n=NULL) { |
224 | 224 | r <- range(x, na.rm=TRUE) |
225 | 225 | if(diff(r) == 0) return(r[1L]) |
226 | 226 | ## call 'pretty' after removing any NULL arguments |
227 | | - p <- do.call(pretty, resolve.defaults(list(x=quote(x), ...), |
| 227 | + p <- do.call(pretty, resolve.defaults(list(x=quote(x), ..., n=n), |
228 | 228 | .MatchNull=FALSE, |
229 | 229 | .StripNull=TRUE)) |
230 | | - ok <- inside.range(p, r) |
231 | | - return(p[ok]) |
| 230 | + p <- p[inside.range(p, r)] |
| 231 | + if(!is.null(n) && length(p) < n) { |
| 232 | + p <- do.call(pretty, resolve.defaults(list(x=quote(x), ..., n=n+2), |
| 233 | + .MatchNull=FALSE, |
| 234 | + .StripNull=TRUE)) |
| 235 | + p <- p[inside.range(p, r)] |
| 236 | + } |
| 237 | + return(p) |
232 | 238 | } |
233 | 239 |
|
234 | 240 | prettydiscrete <- function(x, n=10) { |
|
0 commit comments