From 029f973524d151f401da91c3cda5e7b38938fb58 Mon Sep 17 00:00:00 2001 From: yun Date: Wed, 26 Jun 2024 21:46:06 +0800 Subject: [PATCH] eaano: matrix function can return a simple vector or data.frame --- R/eanno.R | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/R/eanno.R b/R/eanno.R index 918ff82..154f700 100644 --- a/R/eanno.R +++ b/R/eanno.R @@ -310,9 +310,15 @@ methods::setMethod( row = heat_matrix, column = t(heat_matrix) ) - if (!is.matrix(mat <- mat(data))) { - cli::cli_abort("{.fn @matrix} of {id} must return a matrix") - } + mat <- tryCatch( + build_matrix(mat(data)), + function(cnd) { + cli::cli_abort(paste( + "{.fn @matrix} of {id} must return a {.cls matrix},", + "a simple vector, or a {.cls data.frame}." + )) + } + ) object@n <- nrow(mat) } object@matrix <- mat