From 3de28729e8ce399c615b8924d4263b922a2b1fb7 Mon Sep 17 00:00:00 2001 From: sjevelazco Date: Mon, 19 Feb 2024 16:03:43 -0300 Subject: [PATCH] min change in occfilt_geo --- DESCRIPTION | 2 +- R/occfilt_geo.R | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bc9f8487..df43ed49 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,7 +44,7 @@ Description: Assist in the construction of flexible species distribution workflo License: GPL (>= 3) Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Suggests: covr, knitr, diff --git a/R/occfilt_geo.R b/R/occfilt_geo.R index 8780ca99..150de874 100644 --- a/R/occfilt_geo.R +++ b/R/occfilt_geo.R @@ -158,6 +158,7 @@ occfilt_geo <- function(data, x, y, env_layer, method, prj = "+proj=longlat +dat if (sum(!filt) > 0) { message(sum(!filt), " records were removed because they have NAs for some variables") da <- da[filt, ] + data0 <- data0[filt, ] coord <- coord[filt, ] env <- env[filt, ] } @@ -234,6 +235,7 @@ occfilt_geo <- function(data, x, y, env_layer, method, prj = "+proj=longlat +dat }) == max(sapply(occT, function(x) { nrow(x) })))[1]]] + colnames(occT) <- c(x, y) occT <- as.integer(row.names(occT)) # Select Thinned Occurrences @@ -299,15 +301,13 @@ occfilt_geo <- function(data, x, y, env_layer, method, prj = "+proj=longlat +dat ) )) occT <- - occT[[which(sapply(occT, function(x) { - nrow(x) - }) == max(sapply(occT, function(x) { + occT[[which.max(sapply(occT, function(x) { nrow(x) - })))[1]]] - occT <- as.integer(row.names(occT)) + }))[1]]] + colnames(occT) <- c(x, y) # Select Thinned Occurrences - coord_filter <- data0[occT, ] + coord_filter <- data0[which(data0[,x]%in%occT[,x] & data0[,y]%in%occT[,y]), ] message("Distance threshold(km): ", round(as.numeric(method["d"]), 3)) message("Number of filtered records: ", nrow(coord_filter)) }