enrichplot icon indicating copy to clipboard operation
enrichplot copied to clipboard

treeplot not working

Open laijen000 opened this issue 2 years ago • 1 comments

Hello,

treeplot used to work fine for me (R v4.1) but now it is giving me this error. Could you help?

ERROR while rich displaying an object: Error in geom_segment2(): ! Problem while converting geom to grob. ℹ Error occurred in the 3rd layer. Caused by error in check.length(): ! 'gpar' element 'lwd' must not be length 0

Traceback:

  1. tryCatch(withCallingHandlers({ . if (!mime %in% names(repr::mime2repr)) . stop("No repr_* for mimetype ", mime, " in repr::mime2repr") . rpr <- repr::mime2repr[mime] . if (is.null(rpr)) . return(NULL) . prepare_content(is.raw(rpr), rpr) . }, error = error_handler), error = outer_handler)
  2. tryCatchList(expr, classes, parentenv, handlers)
  3. tryCatchOne(expr, names, parentenv, handlers[[1L]])
  4. doTryCatch(return(expr), name, parentenv, handler)
  5. withCallingHandlers({ . if (!mime %in% names(repr::mime2repr)) . stop("No repr_* for mimetype ", mime, " in repr::mime2repr") . rpr <- repr::mime2repr[mime] . if (is.null(rpr)) . return(NULL) . prepare_content(is.raw(rpr), rpr) . }, error = error_handler)
  6. repr::mime2repr[mime]
  7. repr_text.default(obj)
  8. paste(capture.output(print(obj)), collapse = "\n")
  9. capture.output(print(obj))
  10. withVisible(...elt(i))
  11. print(obj)
  12. print.ggplot(obj)
  13. ggplot_gtable(data)
  14. ggplot_gtable.ggplot_built(data)
  15. by_layer(function(l, d) l$draw_geom(d, layout), plot$layers, . data, "converting geom to grob")
  16. try_fetch(for (i in seq_along(data)) { . out[[i]] <- f(l = layers[[i]], d = data[[i]]) . }, error = function(cnd) { . cli::cli_abort(c("Problem while {step}.", i = "Error occurred in the {ordinal(i)} layer."), . call = layers[[i]]$constructor, parent = cnd) . })
  17. tryCatch(withCallingHandlers(expr, condition = function(cnd) { . { . .handler_frame. <- TRUE . .setup_frame. <- frame . if (inherits(cnd, "message")) { . except <- c("warning", "error") . } . else if (inherits(cnd, "warning")) { . except <- "error" . } . else { . except <- "" . } . } . while (!is_null(cnd)) { . if (inherits(cnd, "error")) { . out <- handlers[1L] . if (!inherits(out, "rlang_zap")) . throw(out) . } . inherit <- .subset2(.subset2(cnd, "rlang"), "inherit") . if (is_false(inherit)) { . return() . } . cnd <- .subset2(cnd, "parent") . } . }), stackOverflowError = handlers[[1L]])
  18. tryCatchList(expr, classes, parentenv, handlers)
  19. tryCatchOne(expr, names, parentenv, handlers[[1L]])
  20. doTryCatch(return(expr), name, parentenv, handler)
  21. withCallingHandlers(expr, condition = function(cnd) { . { . .handler_frame. <- TRUE . .setup_frame. <- frame . if (inherits(cnd, "message")) { . except <- c("warning", "error") . } . else if (inherits(cnd, "warning")) { . except <- "error" . } . else { . except <- "" . } . } . while (!is_null(cnd)) { . if (inherits(cnd, "error")) { . out <- handlers[1L] . if (!inherits(out, "rlang_zap")) . throw(out) . } . inherit <- .subset2(.subset2(cnd, "rlang"), "inherit") . if (is_false(inherit)) { . return() . } . cnd <- .subset2(cnd, "parent") . } . })
  22. f(l = layers[[i]], d = data[[i]])
  23. l$draw_geom(d, layout)
  24. draw_geom(..., self = self)
  25. self$geom$draw_layer(data, self$computed_geom_params, layout, . layout$coord)
  26. draw_layer(..., self = self)
  27. lapply(split(data, data$PANEL), function(data) { . if (empty(data)) . return(zeroGrob()) . panel_params <- layout$panel_params[[data$PANEL[1]]] . inject(self$draw_panel(data, panel_params, coord, !!!params)) . })
  28. FUN(X[[i]], ...)
  29. inject(self$draw_panel(data, panel_params, coord, !!!params))
  30. self$draw_panel(data, panel_params, coord, arrow = NULL, lineend = "butt", . na.rm = FALSE, nudge_x = 0.432898555929542)
  31. draw_panel(...)
  32. grid::segmentsGrob(data$x, data$y, data$xend, data$yend, default.units = "native", . gp = gpar(col = alpha(data$colour, data$alpha), fill = alpha(arrow.fill, . data$alpha), lwd = data$size * ggplot2::.pt, lty = data$linetype, . lineend = lineend, linejoin = linejoin), arrow = arrow)
  33. grob(x0 = x0, y0 = y0, x1 = x1, y1 = y1, arrow = arrow, name = name, . gp = gp, vp = vp, cl = "segments")
  34. gpar(col = alpha(data$colour, data$alpha), fill = alpha(arrow.fill, . data$alpha), lwd = data$size * ggplot2::.pt, lty = data$linetype, . lineend = lineend, linejoin = linejoin)
  35. validGP(list(...))
  36. numnotnull("lwd")
  37. check.length(gparname)
  38. stop(gettextf("'gpar' element '%s' must not be length 0", gparname), . domain = NA)
  39. .handleSimpleError(function (cnd) . { . { . .handler_frame. <- TRUE . .setup_frame. <- frame . if (inherits(cnd, "message")) { . except <- c("warning", "error") . } . else if (inherits(cnd, "warning")) { . except <- "error" . } . else { . except <- "" . } . } . while (!is_null(cnd)) { . if (inherits(cnd, "error")) { . out <- handlers[1L] . if (!inherits(out, "rlang_zap")) . throw(out) . } . inherit <- .subset2(.subset2(cnd, "rlang"), "inherit") . if (is_false(inherit)) { . return() . } . cnd <- .subset2(cnd, "parent") . } . }, "'gpar' element 'lwd' must not be length 0", base::quote(check.length(gparname)))
  40. h(simpleError(msg, call))
  41. handlers[1L]
  42. cli::cli_abort(c("Problem while {step}.", i = "Error occurred in the {ordinal(i)} layer."), . call = layers[[i]]$constructor, parent = cnd)
  43. rlang::abort(message, ..., call = call, use_cli_format = TRUE, . .frame = .frame)
  44. signal_abort(cnd, .file)

laijen000 avatar Mar 21 '23 20:03 laijen000