Skip to content

Instantly share code, notes, and snippets.

@JosiahParry
Created September 19, 2022 17:15
Show Gist options
  • Save JosiahParry/4c74163e1967b2d591e6d7192a932f44 to your computer and use it in GitHub Desktop.
Save JosiahParry/4c74163e1967b2d591e6d7192a932f44 to your computer and use it in GitHub Desktop.
data(guerry, package = "sfdep")
library(dplyr)
library(spdep)
transmute(guerry, neighbors = spdep::poly2nb(geometry))
class_modify <- function(x, class = "list") {
current <- class(x)
class(x) <- c(current, class)
x
}
transmute(guerry, neighbors = class_modify(spdep::poly2nb(geometry)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment