diff --git a/R/squeeze.R b/R/squeeze.R index f13afa8..8030894 100644 --- a/R/squeeze.R +++ b/R/squeeze.R @@ -6,17 +6,10 @@ #' a 3-by-1-by-1-by-2 array, then squeeze(A) returns a 3-by-2 matrix. If A is a #' row vector, column vector, scalar, or an array with no dimensions of length #' 1, then squeeze returns the input A. +#' @note This is basically a wrapper of drop() with a minor adjustment to adapt +#' the output to what happens on Matlab #' @param A input or array matrix #' @return An array with the same elements as the input array, but with #' dimensions of length 1 removed. #' @author Waldir Leoncio -squeeze <- function(A) { - A <- as.array(A) - dim_1 <- which(dim(A) == 1) - B <- array(A, dim = dim(A)[-dim_1]) - - # Workaround to match Matlab behavior - if (length(dim(B)) == 1) B <- as.matrix(B) - - return(B) -} \ No newline at end of file +squeeze <- function(A) as.matrix(drop(A)) \ No newline at end of file diff --git a/man/squeeze.Rd b/man/squeeze.Rd index 6e495e2..6191ee4 100644 --- a/man/squeeze.Rd +++ b/man/squeeze.Rd @@ -24,6 +24,10 @@ a 3-by-1-by-1-by-2 array, then squeeze(A) returns a 3-by-2 matrix. If A is a row vector, column vector, scalar, or an array with no dimensions of length 1, then squeeze returns the input A. } +\note{ +This is basically a wrapper of drop() with a minor adjustment to adapt +the output to what happens on Matlab +} \author{ Waldir Leoncio }