Added list output to cell()
This commit is contained in:
parent
d16de2ba7d
commit
e1642f24e5
1 changed files with 6 additions and 1 deletions
7
R/cell.R
7
R/cell.R
|
|
@ -2,9 +2,14 @@
|
||||||
#' @description Creates an array of zeros
|
#' @description Creates an array of zeros
|
||||||
#' @param n a the first dimension (or both, if sz is not passed)
|
#' @param n a the first dimension (or both, if sz is not passed)
|
||||||
#' @param sz the second dimension (or 1st and 2nd, if not passed)
|
#' @param sz the second dimension (or 1st and 2nd, if not passed)
|
||||||
|
#' @param expandable if TRUE, output is a list (so it can take different
|
||||||
|
#' lengths)
|
||||||
#' @param ... Other dimensions
|
#' @param ... Other dimensions
|
||||||
#' @return An array of zeroes with the dimensions passed on call
|
#' @return An array of zeroes with the dimensions passed on call
|
||||||
cell <- function(n, sz = c(n, n), ...) {
|
cell <- function(n, sz = c(n, n), expandable=FALSE, ...) {
|
||||||
|
if (expandable) {
|
||||||
|
return(vector("list", length = n))
|
||||||
|
}
|
||||||
if (length(sz) == 1 & missing(...)) {
|
if (length(sz) == 1 & missing(...)) {
|
||||||
return(array(0, dim = c(n, sz)))
|
return(array(0, dim = c(n, sz)))
|
||||||
} else if (length(sz) == 2) {
|
} else if (length(sz) == 2) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue