Commit 0b940ec8 authored by David's avatar David
Browse files

fix(plot.GRiwrm): no crash with single node

Refs #153
Showing with 11 additions and 7 deletions
+11 -7
...@@ -49,13 +49,17 @@ plot.GRiwrm <- function(x, ...@@ -49,13 +49,17 @@ plot.GRiwrm <- function(x,
x <- sortGRiwrm4plot(x) x <- sortGRiwrm4plot(x)
nodes <- unlist(sapply(unique(x$donor), plotGriwrmCluster, x = x, with_donors = with_donors)) nodes <- unlist(sapply(unique(x$donor), plotGriwrmCluster, x = x, with_donors = with_donors))
g2 <- x[!is.na(x$down),] g2 <- x[!is.na(x$down),]
links <- paste( if (nrow(g2) > 0) {
sprintf("id_%1$s", g2$id), links <- paste(
"-->|", sprintf("id_%1$s", g2$id),
round(g2$length, digits = 0), "-->|",
"km|", round(g2$length, digits = 0),
sprintf("id_%1$s", g2$down) "km|",
) sprintf("id_%1$s", g2$down)
)
} else {
links <- ""
}
x$nodeclass <- sapply(x$id, getNodeClass, griwrm = x) x$nodeclass <- sapply(x$id, getNodeClass, griwrm = x)
node_class <- lapply(unique(x$nodeclass), function(nc) { node_class <- lapply(unique(x$nodeclass), function(nc) {
x$id[x$nodeclass == nc] x$id[x$nodeclass == nc]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment