Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
rsbivand committed Aug 31, 2024
1 parent 63aea17 commit 270ccdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion R/nb2mat.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,20 @@ mat2listw <- function(x, row.names=NULL, style=NULL, zero.policy=NULL) {
attr(neighbours, "call") <- NA
attr(neighbours, "sym") <- is.symmetric.nb(neighbours,
verbose=FALSE, force=TRUE)
if (any(card(neighbours) == 0L)) {
cnb <- card(neighbours)
if (any(cnb == 0L)) {
if (!zero.policy) {
warning("no-neighbour observations found, set zero.policy to TRUE;\nthis warning will soon become an error")
}
}

NE <- length(neighbours) + sum(cnb)
if (get.SubgraphOption() && get.SubgraphCeiling() > NE) {
ncomp <- n.comp.nb(neighbours)
attr(neighbours, "ncomp") <- ncomp
if (ncomp$nc > 1) warning("neighbour object has ", ncomp$nc, " sub-graphs")
}

res <- list(style=style, neighbours=neighbours, weights=weights)
class(res) <- c("listw", "nb")
attr(res, "region.id") <- attr(neighbours, "region.id")
Expand Down
2 changes: 1 addition & 1 deletion man/card.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ list.
\details{\dQuote{nb} objects are stored as lists of integer vectors, where the vectors contain either the indices in the range \code{1:n} for \code{n} as \code{length(nb)} of the neighbours of region \code{i}, or \code{as.integer(0)} to signal no neighbours. The function \code{card(nb)} is used to extract the numbers of neighbours from the \dQuote{nb} object.}


\references{Bivand R, Pebesma EJ, Gomez-Rubio V, (2008) \emph{Applied Spatial Data Analysis with R}, Springer, New York, pp. 239-251; Bivand R, Portnov B, (2004) Exploring spatial data analysis techniques using R: the case of observations with no neighbours. In: Anselin L, Florax R, Rey S, (eds.), \emph{Advances in Spatial Econometrics, Methodology, Tools and Applications}. Berlin: Springer-Verlag, pp. 121-142.}
\references{Bivand R, Pebesma EJ, Gomez-Rubio V, (2008) \emph{Applied Spatial Data Analysis with R}, Springer, New York, pp. 239-251; Bivand R, Portnov B, (2004) Exploring spatial data analysis techniques using R: the case of observations with no neighbours. In: Anselin L, Florax R, Rey S, (eds.), \emph{Advances in Spatial Econometrics, Methodology, Tools and Applications}. Berlin: Springer-Verlag, pp. 121-142, \doi{10.1007/978-3-662-05617-2_6}.}


\author{Roger Bivand \email{Roger.Bivand@nhh.no}}
Expand Down

0 comments on commit 270ccdb

Please sign in to comment.