~enricoschumann/neighbours

6fb8efdf03179d8da0d2d77a46c748ecea33cfa8 — Enrico Schumann 2 years ago 3e2d143
Fix "permute" neighbourhoods with stepsize > 2
2 files changed, 9 insertions(+), 2 deletions(-)

M ChangeLog
M R/neighbourfun.R
M ChangeLog => ChangeLog +5 -0
@@ 1,3 1,8 @@
2022-08-10  Enrico Schumann  <es@enricoschumann.net>

        * R/neighbourfun.R (neighbourfun): fix "permute"
        neighbourhoods with stepsize > 2

2022-07-29  Enrico Schumann  <es@enricoschumann.net>

        * R/neighbourfun.R (neighbourfun): rewrite code

M R/neighbourfun.R => R/neighbourfun.R +4 -2
@@ 178,8 178,8 @@ neighbourfun <- function(min = 0,
            }
        } else {
            ans <- function(x, ...) {
                ii <- sample.int(length(x), stepsize)
                x[ii] <- x[sample.int(ii)]
                ii <- sample.int(length(x), size = stepsize)
                x[ii] <- x[sample(ii)]
                x
            }
        }


@@ 307,6 307,8 @@ compare_vectors <- function(...,


    vecs <- list(...)
    if (!is.logical(vecs[[1]]))
        stop("currently only supported for logical vectors")
    len.x <- length(vecs)
    if (length(unique(lengths(vecs))) != 1L)
        stop("vectors have different lengths")