From 71741ddc81e78949cdb5882c087bdfe3ab371960 Mon Sep 17 00:00:00 2001 From: schochastics Date: Thu, 20 Feb 2025 22:13:32 +0100 Subject: [PATCH] fix NA attributes --- R/plot.common.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/R/plot.common.R b/R/plot.common.R index c163d582e28..2a97353bb93 100644 --- a/R/plot.common.R +++ b/R/plot.common.R @@ -502,13 +502,10 @@ i.parse.plot.params <- function(graph, params) { ## we don't have the parameter, check attributes first if (type == "vertex" && name %in% vertex_attr_names(graph)) { p[[type]][[name]] <- vertex_attr(graph, name) - return(ret()) } else if (type == "edge" && name %in% edge_attr_names(graph)) { p[[type]][[name]] <- edge_attr(graph, name) - return(ret()) } else if (type == "plot" && name %in% graph_attr_names(graph)) { p[[type]][[name]] <- graph_attr(graph, name) - return(ret()) } else { ## no attributes either, check igraph parameters n <- paste(sep = "", type, ".", name) @@ -522,6 +519,12 @@ i.parse.plot.params <- function(graph, params) { return(ret()) } } + if (any(is.na(p[[type]][[name]]))) { + cli::cli_warn("{type} attribute {name} contains NAs. Replacing with default value {i.default.values[[type]][[name]] + }") + p[[type]][[name]][is.na(p[[type]][[name]])] <- i.default.values[[type]][[name]] + } + return(ret()) } return(func)