Browse Source

Add function to determine desc_table type

- not a desc_table
- simple desc_table
- grouped desc_table
tags/0.3.0
Maxime Wack 2 years ago
parent
commit
ae504665a1
1 changed files with 22 additions and 0 deletions
  1. +22
    -0
      R/utils.R

+ 22
- 0
R/utils.R View File

@@ -29,3 +29,25 @@ insert <- function(x, y, position) {
# Return a simple vector
unlist(result)
}

#' Is the object possibly a desctable?
#'
#' Check if the object is produced by desc_table.
#' Return a string:
#' - simple
#' - grouped
#' or FALSE if not a desctable
#'
#' @param desctable A potential desctable to check
#' @return The type of desctable or FALSE
which.desctable <- function(desctable)
{
attributes <- list()

if (all(c("data", ".stats", ".vars") %in% names(desctable)))
"grouped"
else if (is.data.frame(desctable) & ("Variables" %in% names(desctable)))
"simple"
else
""
}

Loading…
Cancel
Save