Skip to content

Commit d7a093d

Browse files
committed
Revert "Update spatiotemp_block.R"
This reverts commit 237ffc2.
1 parent 237ffc2 commit d7a093d

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

R/spatiotemp_block.R

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#'approach for model training and testing.
3232
#'
3333
#'We adapt this approach to account for temporal autocorrelation by enabling users to split records
34-
#'into sampling units based upon spatial or temporal characteristics before blocking occurs.
34+
#'into sampling units based upon spatial and temporal characteristic before blocking occurs.
3535
#'
3636
#'# Spatial splitting
3737
#'
@@ -45,6 +45,8 @@
4545
#'considered unique sampling unit. For instance, if `temporal.block` = `year`, then records from the
4646
#'same year are considered a sampling unit to be grouped into blocks.
4747
#'
48+
#'Note: If spatial splitting is also used, then spatial characteristics may split these further into
49+
#'separate sampling units.
4850
#'
4951
#'The `temporal.block` option `quarter` splits occurrence records into sampling units based on which
5052
#'quarter of the year the record month belongs to: (1) January-March, (2) April-June, (3)
@@ -53,7 +55,7 @@
5355
#'
5456
#'# Block generation
5557
#'
56-
#'Once split into sampling units based upon temporal or spatial characteristics, these units are
58+
#'Once split into sampling units based upon temporal and spatial characteristics, these units are
5759
#'then assigned into given number of blocks (`n.blocks`), so that the mean and range of explanatory
5860
#'variables (`vars.to.block.by`) and total sample size are similar across each. The number of
5961
#'`iterations` specifies how many random shuffles are used to optimise block equalisation.
@@ -65,7 +67,7 @@
6567
#' Biology, 19, 1236-1248.
6668
#'
6769
#'@return Returns occurrence data frame with column "BLOCK.CATS", assigning each record to a
68-
#' spatial or temporal block.
70+
#' spatiotemporal block.
6971
#' @examples
7072
#' \donttest{
7173
#'data("sample_explan_data")
@@ -79,6 +81,7 @@
7981
#' occ.data = sample_explan_data,
8082
#' spatial.layer = random_cat_layer,
8183
#' spatial.split.degrees = 3,
84+
#' temporal.block = c("month"),
8285
#' vars.to.block.by = colnames(sample_explan_data)[14:16],
8386
#' n.blocks = 3,
8487
#' iterations = 30
@@ -90,29 +93,24 @@ spatiotemp_block <- function(occ.data,
9093
vars.to.block.by,
9194
spatial.layer,
9295
spatial.split.degrees,
93-
temporal.block ,
96+
temporal.block,
9497
n.blocks = 10,
9598
iterations = 5000) {
9699

97100
# Save occ.data to return with added block column at end
98101
occ.data.save <- occ.data
99102

100-
temporal.block.2 <- NULL
101103
if (n.blocks < 2) {
102104
stop("n.blocks must be over one for blocking")
103105
}
104106

105-
if (!missing(spatial.layer)) {
106-
message("Blocking by spatial features.")
107-
}
108-
109-
if (!missing(spatial.layer) && !missing(temporal.block)) {
110-
stop("Error: Spatial and Temporal Blocking must be applied separately. Provide only one of `spatial.layer` or `temporal.block`.")
107+
if (missing(spatial.layer)) {
108+
message("spatial.layer is missing. No blocking by spatial features.")
111109
}
112110

113-
if (!missing(temporal.block)) {
114-
message("Blocking by temporal features.")
115-
111+
if (missing(temporal.block)) {
112+
message("temporal.block is missing. No blocking by temporal features.")
113+
temporal.block.2 <-NULL
116114
}
117115

118116
if (!missing(temporal.block)) {

0 commit comments

Comments
 (0)