Running examples in ‘raster-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: buffer
> ### Title: buffer
> ### Aliases: buffer buffer,RasterLayer-method buffer,Spatial-method
> ### Keywords: spatial
> 
> ### ** Examples
> 
> r <- raster(ncol=36,nrow=18)
> values(r) <- NA
> r[500] <- 1
> b <- buffer(r, width=5000000) 
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
raster
 --- call from context --- 
.local(x, ...)
 --- call from argument --- 
if (class(pts) == "try-error") {
    d <- .distanceRows(x, filename = filename, ...)
    d <- reclassify(d, rbind(c(-1, width, 1), c(width, Inf, NA)))
    return(d)
}
 --- R stacktrace ---
where 1: .local(x, ...)
where 2: buffer(r, width = 5e+06)
where 3: buffer(r, width = 5e+06)

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (x, width = 0, filename = "", doEdge = FALSE, ...) 
{
    stopifnot(width > 0)
    if (doEdge) {
        r <- boundaries(x, classes = FALSE, type = "inner", progress = .progress(...))
        pts <- try(rasterToPoints(r, fun = function(z) {
            z > 0
        })[, 1:2, drop = FALSE])
    }
    else {
        pts <- try(rasterToPoints(x)[, 1:2, drop = FALSE])
    }
    if (class(pts) == "try-error") {
        d <- .distanceRows(x, filename = filename, ...)
        d <- reclassify(d, rbind(c(-1, width, 1), c(width, Inf, 
            NA)))
        return(d)
    }
    if (nrow(pts) == 0) {
        stop("RasterLayer has no NA cells (for which to compute a distance)")
    }
    out <- raster(x)
    filename <- trim(filename)
    if (couldBeLonLat(x)) {
        longlat = TRUE
    }
    else {
        longlat = FALSE
    }
    if (canProcessInMemory(out, 6)) {
        pb <- pbCreate(4, label = "buffer", ...)
        v <- values(x)
        i <- is.na(v)
        if (!any(i)) {
            stop("raster has no NA values to compute distance to")
        }
        pbStep(pb)
        xy <- xyFromCell(out, which(i))
        vals <- .Call("_raster_distanceToNearestPoint", xy, pts, 
            longlat, 6378137, 1/298.257223563, PACKAGE = "raster")
        pbStep(pb)
        v[!i] <- 1
        v[i] <- NA^(vals > width)
        out <- setValues(out, v)
        pbStep(pb)
        if (filename != "") {
            out <- writeRaster(out, filename = filename, ...)
        }
        pbStep(pb)
        pbClose(pb)
        return(out)
    }
    out <- writeStart(out, filename = filename, ...)
    tr <- blockSize(out)
    pb <- pbCreate(tr$n, label = "buffer", ...)
    xy <- cbind(rep(xFromCol(out, 1:ncol(out)), tr$nrows[1]), 
        NA)
    for (i in 1:tr$n) {
        if (i == tr$n) {
            xy <- xy[1:(ncol(out) * tr$nrows[i]), ]
        }
        xy[, 2] <- rep(yFromRow(out, tr$row[i]:(tr$row[i] + tr$nrows[i] - 
            1)), each = ncol(out))
        vals <- getValues(x, tr$row[i], tr$nrows[i])
        j <- which(is.na(vals))
        vals[] <- 0
        if (length(j) > 0) {
            vals[j] <- .Call("_raster_distanceToNearestPoint", 
                xy[j, , drop = FALSE], pts, longlat, 6378137, 
                1/298.257223563, PACKAGE = "raster")
        }
        vals[vals > width] <- NA
        vals[!is.na(vals)] <- 1
        out <- writeValues(out, vals, tr$row[i])
        pbStep(pb)
    }
    pbClose(pb)
    out <- writeStop(out)
    return(out)
}
<environment: namespace:raster>
 --- function search by body ---
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1