Calculate correlation

## Usage

calculate_correlation(
metrics,
method = "pearson",
diag = TRUE,
simplify = FALSE
)

## Arguments

metrics

Tibble with results of as returned by the landscapemetrics package.

method

Type of correlation. See link{cor} for details.

diag

If FALSE, values on the diagonal will be NA.

simplify

If TRUE and only one level is present, only a tibble is returned.

list

## Details

The functions calculates the correlation between all metrics. In order to calculate correlations, for the landscape level more than one landscape needs to be present. All input must be structured as returned by the landscapemetrics package.

## Examples

landscape <- terra::rast(landscapemetrics::landscape)
metrics <- calculate_lsm(landscape, what = c("patch", "class"))
#> Warning: Please use 'check_landscape()' to ensure the input data is valid.
#> Warning: Class 1: PAFRAC = NA for class with < 10 patches
#> Warning: Class 3: PAFRAC = NA for class with < 10 patches
calculate_correlation(metrics, method = "pearson")
#> $patch #> # A tibble: 78 × 3 #> metric_1 metric_2 value #> <chr> <chr> <dbl> #> 1 area area 1 #> 2 cai area 0.886 #> 3 circle area 0.511 #> 4 contig area 0.742 #> 5 core area 0.987 #> 6 enn area -0.443 #> 7 frac area 0.318 #> 8 gyrate area 0.952 #> 9 ncore area 0.702 #> 10 para area -0.709 #> # ℹ 68 more rows #> #>$class
#> # A tibble: 1,486 × 3
#>    metric_1  metric_2  value
#>    <chr>     <chr>     <dbl>
#>  1 ai        ai        1
#>  2 area_cv   ai       -0.926
#>  3 area_mn   ai        1.00
#>  4 area_sd   ai        0.986
#>  5 ca        ai        0.986
#>  6 cai_cv    ai       -0.973
#>  7 cai_mn    ai        0.997
#>  8 cai_sd    ai        0.984
#>  9 circle_cv ai       -0.983
#> 10 circle_mn ai        0.990
#> # ℹ 1,476 more rows
#>