ourMELONS/R/isempty.R
Waldir Leoncio fca9caa731 Restyled files
Ran through styler::style_dir() in the R and tests directories in preparation for #23.
2021-11-10 14:25:50 +01:00

13 lines
467 B
R

#' @title Is Array Empty?
#' @description Determine whether array is empty. An empty array, table, or timetable has at least one dimension with length 0, such as 0-by-0 or 0-by-5.
#' @details Emulates the behavior of the `isempty` function on Matlab
#' @param x array
#'
isempty <- function(x) {
if (class(x)[1] %in% c("array", "matrix")) {
dim_mat_x <- dim(x)
} else {
dim_mat_x <- dim(matrix(x))
}
return(any(dim_mat_x == 0) | is.null(dim_mat_x))
}