diff --git a/R-package/R/xgb.plot.multi.trees.R b/R-package/R/xgb.plot.multi.trees.R index 063f1034a..fc54d777d 100644 --- a/R-package/R/xgb.plot.multi.trees.R +++ b/R-package/R/xgb.plot.multi.trees.R @@ -62,6 +62,9 @@ #' @export xgb.plot.multi.trees <- function(model, feature_names = NULL, features_keep = 5, plot_width = NULL, plot_height = NULL, render = TRUE, ...){ + if (!requireNamespace("DiagrammeR", quietly = TRUE)) { + stop("DiagrammeR is required for xgb.plot.multi.trees") + } check.deprecation(...) tree.matrix <- xgb.model.dt.tree(feature_names = feature_names, model = model)