diff --git a/NEWS.md b/NEWS.md index 4d1cf9e2..1b4dfbc5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # Version 1.3-2 (development) +* #143 `row.names` pass-through in `poly2nb` corrected, harmonised `row.names` pass-through also in `nbdists` and `dnearneigh` + * #139 add `na.action` argument to `geary.test`, `geary.mc` and `globalG.test` * add `style` to `sn2listw` use in `tri2nb` diff --git a/R/dnearneigh.R b/R/dnearneigh.R index 5264eb39..07bb977e 100644 --- a/R/dnearneigh.R +++ b/R/dnearneigh.R @@ -16,6 +16,7 @@ dnearneigh <- function(x, d1, d2, row.names=NULL, longlat=NULL, bounds=c("GE", " && !is.na(is.projected(x)) && !is.projected(x)) { longlat <- TRUE } else longlat <- FALSE + if (is.null(row.names)) row.names <- row.names(x) x <- coordinates(x) } else if (inherits(x, "sf") || inherits(x, "sfc")) { if (inherits(x, "sf")) { diff --git a/R/nbdists.R b/R/nbdists.R index 65c2c09c..34ad8b84 100644 --- a/R/nbdists.R +++ b/R/nbdists.R @@ -15,6 +15,7 @@ nbdists <- function(nb, coords, longlat=NULL) { && !is.na(is.projected(coords)) && !is.projected(coords)) { longlat <- TRUE } else longlat <- FALSE + if (is.null(row.names)) row.names <- row.names(coords) coords <- coordinates(coords)[, 1:2] } else if (inherits(coords, "sf") || inherits(coords, "sfc")) { if (inherits(coords, "sf")) { diff --git a/R/poly2nb.R b/R/poly2nb.R index ba6c046a..fa83c553 100644 --- a/R/poly2nb.R +++ b/R/poly2nb.R @@ -14,7 +14,7 @@ poly2nb <- function(pl, row.names=NULL, snap=sqrt(.Machine$double.eps), sf <- FALSE } else { if (inherits(pl, "sf")) { - row.names <- row.names(pl) + if (is.null(row.names)) row.names <- row.names(pl) regid <- NULL pl <- sf::st_geometry(pl) }