partition_data: Partition spatial data

Description Usage Arguments Value Examples

View source: R/partition_data.r

Description

A function that partitions spatial data in order to avoid spatial autocorrelation.

Usage

1
partition_data(dataset_raster, dataset, env, method)

Arguments

dataset_raster

A raster dataset.

dataset

A dataframe containing species occurrences.

env

A raster dataset containing the environmental variables.

method

A character string representing the desired spatial partitioning method. Can be "default", "block", "checkerboard1", or "checkerboard2".

Value

A dataframe partitioned using the selected method.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## Not run: 
# download benchmarking data
benchmarking_data <- get_benchmarking_data("Lynx lynx",
                                           limit = 1500)

# apply data partitioning to benchmarking data
# note that this function overwrites the data
benchmarking_data$df_data <- partition_data(
     dataset_raster = benchmarking_data$raster_data,
     dataset = benchmarking_data$df_data,
     env = benchmarking_data$raster_data$climate_variables,
     method = "block")

# to inspect the partitioning results you can get a contingency table on the
# newly created grouping factor
# in this case you should see four different groups
table(benchmarking_data$df_data$label)

# use a different spatial partitioning method
benchmarking_data$df_data <- partition_data(
     dataset_raster = benchmarking_data$raster_data,
     dataset = benchmarking_data$df_data,
     env = benchmarking_data$raster_data$climate_variables,
     method = "checkerboard1")

# you can perform a sanity check here as well, you should see two groups
table(benchmarking_data$df_data$label)

## End(Not run)

boyanangelov/sdmbench documentation built on Dec. 14, 2020, 1:08 a.m.