Added base Matlab function

This commit is contained in:
Waldir Leoncio 2020-03-18 08:25:50 +01:00
parent e5cf85d9d4
commit 4c4390f419
3 changed files with 45 additions and 0 deletions

13
R/isempty.R Normal file
View file

@ -0,0 +1,13 @@
#' @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) %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))
}