Description Usage Arguments Value Examples
View source: R/partition_data.r
A function that partitions spatial data in order to avoid spatial autocorrelation.
1 | partition_data(dataset_raster, dataset, env, method)
|
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". |
A dataframe partitioned using the selected method.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.