Running examples in 'landscapemetrics-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: calculate_correlation
> ### Title: Calculate correlation
> ### Aliases: calculate_correlation
> 
> ### ** Examples
> 
> metrics <- calculate_lsm(landscape, what = c("patch", "class"))
Warning: Please use check_landscape() to ensure the input data is valid.
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
landscapemetrics
 --- call from context --- 
(function (landscape, directions, resolution = NULL) 
{
    if (class(landscape) != "matrix") {
        resolution <- raster::res(landscape)
        landscape <- raster::as.matrix(landscape)
    }
    factor_ha <- prod(resolution)/10000
    classes <- get_unique_values(landscape)[[1]]
    area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
        landscape_labeled <- get_patches(landscape, class = patches_class, 
            directions = directions, return_raster = FALSE)[[1]]
        area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
            factor_ha
        tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
    }))
    tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
        id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
        value = as.double(area_patch$value))
})(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 2L, 2L, 2L, 2L, 2L, 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L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
1))
 --- call from argument --- 
if (class(landscape) != "matrix") {
    resolution <- raster::res(landscape)
    landscape <- raster::as.matrix(landscape)
}
 --- R stacktrace ---
where 1: (function (landscape, directions, resolution = NULL) 
{
    if (class(landscape) != "matrix") {
        resolution <- raster::res(landscape)
        landscape <- raster::as.matrix(landscape)
    }
    factor_ha <- prod(resolution)/10000
    classes <- get_unique_values(landscape)[[1]]
    area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
        landscape_labeled <- get_patches(landscape, class = patches_class, 
            directions = directions, return_raster = FALSE)[[1]]
        area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
            factor_ha
        tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
    }))
    tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
        id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
        value = as.double(area_patch$value))
})(landscape = c(1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 
3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
1L, 3L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 
3L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 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L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
3L, 3L, 1L, 3L, 3L, 3L, 2L, 2L, 2L), directions = 8, resolution = c(1, 
1))
where 2: do.call(what = foo, args = mget(arguments, envir = parent.env(environment())))
where 3: doTryCatch(return(expr), name, parentenv, handler)
where 4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
where 5: tryCatchList(expr, classes, parentenv, handlers)
where 6: tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
    error = function(e) {
        message("")
        stop(e)
    })
where 7: FUN(X[[i]], ...)
where 8: lapply(seq_along(metrics_calc), FUN = function(current_metric) {
    if (progress) {
        message("\r> Progress metrics: ", current_metric, "/", 
            number_metrics, appendLF = FALSE)
    }
    foo <- get(metrics_calc[[current_metric]], mode = "function")
    arguments <- names(formals(foo))
    tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
        error = function(e) {
            message("")
            stop(e)
        })
})
where 9: do.call(rbind, lapply(seq_along(metrics_calc), FUN = function(current_metric) {
    if (progress) {
        message("\r> Progress metrics: ", current_metric, "/", 
            number_metrics, appendLF = FALSE)
    }
    foo <- get(metrics_calc[[current_metric]], mode = "function")
    arguments <- names(formals(foo))
    tryCatch(do.call(what = foo, args = mget(arguments, envir = parent.env(environment()))), 
        error = function(e) {
            message("")
            stop(e)
        })
}))
where 10: FUN(X[[i]], ...)
where 11: lapply(X = raster::as.list(landscape), FUN = calculate_lsm_internal, 
    level = level, metric = metric, name = name, type = type, 
    what = what, directions = directions, count_boundary = count_boundary, 
    consider_boundary = consider_boundary, edge_depth = edge_depth, 
    classes_max = classes_max, neighbourhood = neighbourhood, 
    ordered = ordered, base = base, full_name = full_name, verbose = verbose, 
    progress = progress)
where 12: calculate_lsm.RasterLayer(landscape, what = c("patch", "class"))
where 13: calculate_lsm(landscape, what = c("patch", "class"))

 --- value of length: 2 type: logical ---
[1] FALSE  TRUE
 --- function from context --- 
function (landscape, directions, resolution = NULL) 
{
    if (class(landscape) != "matrix") {
        resolution <- raster::res(landscape)
        landscape <- raster::as.matrix(landscape)
    }
    factor_ha <- prod(resolution)/10000
    classes <- get_unique_values(landscape)[[1]]
    area_patch <- do.call(rbind, lapply(classes, function(patches_class) {
        landscape_labeled <- get_patches(landscape, class = patches_class, 
            directions = directions, return_raster = FALSE)[[1]]
        area_patch_ij <- rcpp_get_composition_vector(x = landscape_labeled) * 
            factor_ha
        tibble::tibble(class = as.integer(patches_class), value = area_patch_ij)
    }))
    tibble::tibble(level = "patch", class = as.integer(area_patch$class), 
        id = as.integer(seq_len(nrow(area_patch))), metric = "area", 
        value = as.double(area_patch$value))
}
<bytecode: 0xa5d5bf0>
<environment: namespace:landscapemetrics>
 --- function search by body ---
Function lsm_p_area_calc in namespace landscapemetrics has this body.
 ----------- END OF FAILURE REPORT -------------- 

Error in if (class(landscape) != "matrix") { : 
  the condition has length > 1
Calls: calculate_lsm ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted