diff --git a/DESCRIPTION b/DESCRIPTION index 9c877282..8da78653 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: spatsoc Title: Group Animal Relocation Data by Spatial and Temporal Relationship -Version: 0.1.11 +Version: 0.1.12 Authors@R: c(person(given = "Alec L.", family = "Robitaille", diff --git a/NEWS.md b/NEWS.md index 51a0cb45..a1ab280a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ +# v 0.1.12 (2020-03-02) +* fixed `data.table` error in `edge_dist` and `edge_nn` ([PR 25](https://github.com/ropensci/spatsoc/pull/25)) + + # v 0.1.11 (2020-02-20) -* removed default NULL from 'timegroup' arguments in `group_pts`, `edge_dist` and `edge_nn` ([PR 21](https://github.com/ropensci/spatsoc/pull/24)) +* removed default NULL from 'timegroup' arguments in `group_pts`, `edge_dist` and `edge_nn` ([PR 24](https://github.com/ropensci/spatsoc/pull/24)) # v 0.1.10 (2019-06-06) diff --git a/R/edge_dist.R b/R/edge_dist.R index c4636c1c..53f012a8 100644 --- a/R/edge_dist.R +++ b/R/edge_dist.R @@ -133,16 +133,18 @@ edge_dist <- function(DT = NULL, distMatrix <- as.matrix(stats::dist(.SD[, 2:3], method = 'euclidean')) diag(distMatrix) <- NA + w <- which(distMatrix < threshold, arr.ind = TRUE) if (returnDist) { - list(ID1 = .SD[[1]][w[, 1]], - ID2 = .SD[[1]][w[, 2]], - distance = distMatrix[w]) + l <- list(ID1 = .SD[[1]][w[, 1]], + ID2 = .SD[[1]][w[, 2]], + distance = distMatrix[w]) } else { - list(ID1 = .SD[[1]][w[, 1]], - ID2 = .SD[[1]][w[, 2]]) + l <- list(ID1 = .SD[[1]][w[, 1]], + ID2 = .SD[[1]][w[, 2]]) } + l }, by = splitBy, .SDcols = c(id, coords)] diff --git a/R/edge_nn.R b/R/edge_nn.R index 26d7ca6b..a1e87f14 100644 --- a/R/edge_nn.R +++ b/R/edge_nn.R @@ -153,13 +153,14 @@ edge_nn <- function(DT = NULL, if (returnDist) { w <- wm + (length(wm) * (as.numeric(names(wm)) - 1)) - list(ID = .SD[[1]][as.numeric(names(wm))], - NN = .SD[[1]][wm], - distance = distMatrix[w]) + l <- list(ID = .SD[[1]][as.numeric(names(wm))], + NN = .SD[[1]][wm], + distance = distMatrix[w]) } else { - list(ID = .SD[[1]][as.numeric(names(wm))], - NN = .SD[[1]][wm]) + l <- list(ID = .SD[[1]][as.numeric(names(wm))], + NN = .SD[[1]][wm]) } + l }, by = splitBy, .SDcols = c(id, coords)] }