Skip to content

[ggplot2 v4] [Network] Error: Error in as_discrete_pal() #21

@pwwang

Description

@pwwang
actors <- data.frame(
   name = c("Alice", "Bob", "Cecil", "David", "Esmeralda"),
   age = c(48, 33, 45, 34, 21),
   shape = c(21, 22, 21, 22, 23),
   gender = c("F", "M", "F", "M", "F")
)

relations <- data.frame(
   from = c("Bob", "Cecil", "Cecil", "David", "David", "Esmeralda", "Bob", "Alice",
      "Cecil", "David"),
   to = c("Alice", "Bob", "Alice", "Alice", "Bob", "Alice", "Bob", "Alice", "Cecil",
      "David"),
   friendship = c(4, 5, 5, 2, 1, 1, 2, 1, 3, 4),
   type = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2)
)

Network(relations, actors, link_weight_by = "friendship", node_size_by = "age",
  link_weight_name = "FRIENDSHIP", node_fill_by = "gender", link_color_by = "to",
  link_type_by = "type", node_color_by = "black", layout = "circle", link_curvature = 0.2)
ERROR while rich displaying an object: Error in `as_discrete_pal()`:
! Cannot convert `x` to a discrete palette.

Traceback:
1. sapply(x, f, simplify = simplify)
2. lapply(X = X, FUN = FUN, ...)
3. FUN(X[[i]], ...)
4. tryCatch(withCallingHandlers({
 .     if (!mime %in% names(repr::mime2repr)) 
 .         stop("No repr_* for mimetype ", mime, " in repr::mime2repr")
 .     rpr <- repr::mime2repr[[mime]](obj)
 .     if (is.null(rpr)) 
 .         return(NULL)
 .     prepare_content(is.raw(rpr), rpr)
 . }, error = error_handler), error = outer_handler)
5. tryCatchList(expr, classes, parentenv, handlers)
6. tryCatchOne(expr, names, parentenv, handlers[[1L]])
7. doTryCatch(return(expr), name, parentenv, handler)
8. withCallingHandlers({
 .     if (!mime %in% names(repr::mime2repr)) 
 .         stop("No repr_* for mimetype ", mime, " in repr::mime2repr")
 .     rpr <- repr::mime2repr[[mime]](obj)
 .     if (is.null(rpr)) 
 .         return(NULL)
 .     prepare_content(is.raw(rpr), rpr)
 . }, error = error_handler)
9. repr::mime2repr[[mime]](obj)
10. repr_text.default(obj)
11. paste(capture.output(print(obj)), collapse = "\n")
12. capture.output(print(obj))
13. withVisible(...elt(i))
14. print(obj)
15. `print.ggplot2::ggplot`(obj)
16. ggplot_build(x)
17. ggplot_build.ggraph(x)
18. NextMethod()
19. `ggplot_build.ggplot2::ggplot`(x)
20. npscales$set_palettes(plot@theme)
21. set_palettes(..., self = self)
22. as_discrete_pal(elem)
23. as_discrete_pal.default(elem)
24. cli::cli_abort("Cannot convert {.arg x} to a discrete palette.")
25. rlang::abort(message, ..., call = call, use_cli_format = TRUE, 
  .     .frame = .frame)
26. signal_abort(cnd, .file)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions