From a217c1ab896046412819776da6b8c2b644b3c790 Mon Sep 17 00:00:00 2001 From: Sean Hackett Date: Mon, 9 Sep 2024 13:03:03 -0700 Subject: [PATCH] updated get_design_tbl to work with just the design --- R/design.R | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/R/design.R b/R/design.R index ef5d0d1..7657a5a 100644 --- a/R/design.R +++ b/R/design.R @@ -2,15 +2,25 @@ #' #' Get a tabular summary of all variables. #' -#' @inheritParams tomic_to +#' @param tomic_or_design Either a \code{tomic} object or its embedded design list #' #' @returns a tibble reflecting the \code{tomic} object's design. #' #' @examples #' get_design_tbl(brauer_2008_triple) +#' get_design_tbl(brauer_2008_triple$design) +#' #' @export -get_design_tbl <- function(tomic) { - tomic$design[c("features", "samples", "measurements")] %>% +get_design_tbl <- function(tomic_or_design) { + + if (inherits(tomic_or_design, "tomic")) { + design <- tomic_or_design$design + } else { + check_design(tomic_or_design) + design <- tomic_or_design + } + + design[c("features", "samples", "measurements")] %>% { purrr::map2(unname(.), names(.), function(x, y) { x %>%