From 4a63c02d388284d84d5cdfc62e9f68ad3d99c595 Mon Sep 17 00:00:00 2001 From: Roger Bivand Date: Sun, 24 Nov 2024 16:46:53 +0100 Subject: [PATCH] fix SWM write example --- NEWS.md | 9 ++++++++- R/read.gwt2nb.R | 11 ++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index efaeda0..c061b7c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,11 @@ -# Version 1.3-6 (development) +# Version 1.3-7.1 (development) + +* add `write.swmdbf` #171 to complement #163 + +* modify defaults for `licd_multi` + +# Version 1.3-6 (2024-09-13) + * adding vignette describing recent changes in `poly2nb` from #162, subgraph and no-neighbour (island) handling diff --git a/R/read.gwt2nb.R b/R/read.gwt2nb.R index 742a1b2..31e5ce7 100644 --- a/R/read.gwt2nb.R +++ b/R/read.gwt2nb.R @@ -164,11 +164,12 @@ write.sn2DBF <- function(sn, file) { nms <- as.character(attr(sn, "region.id")) sn[,1] <- as.integer(nms[sn[,1]]) sn[,2] <- as.integer(nms[sn[,2]]) - sn <- cbind(data.frame(Field1=rep(0L, nrow(sn))), sn) - if (requireNamespace("foreign", quietly=TRUE)) { - foreign::write.dbf(sn, file) - } else warning("foreign::read.dbf not available") - invisible(sn) + names(sn)[1:2] <- c("ID", "NID") + sn <- cbind(data.frame(Field1=rep(0L, nrow(sn))), sn) + if (requireNamespace("foreign", quietly=TRUE)) { + foreign::write.dbf(sn, file) + } else warning("foreign::read.dbf not available") + invisible(sn) } # Copyright 2011 Virgilio Gomez-Rubio