p = c("sf", "sp")
if(any(!unlist(lapply(p, requireNamespace, quietly=TRUE)))) {
m = which(!unlist(lapply(p, requireNamespace, quietly=TRUE)))
message("Can't run examples, please install ", paste(p[m], collapse = " "))
} else {
invisible(lapply(p, require, character.only=TRUE))
data(meuse, package = "sp")
meuse <- sf::st_as_sf(meuse, coords = c("x", "y"),
crs = 28992, agr = "constant")
nni(meuse)
}
Run the code above in your browser using DataLab