From c9c9b7cb261dbe16780f804b5f6849fd898fb554 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Thu, 30 Jan 2020 17:31:25 +0100 Subject: [PATCH] Fixed handling of empty x argument --- NAMESPACE | 1 + R/size.R | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 673ff82..927db13 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,6 +17,7 @@ export(repmat) export(simulateAllFreqs) export(simulateIndividuals) export(simuloiAlleeli) +export(size) export(suoritaMuutos) export(times) importFrom(stats,runif) diff --git a/R/size.R b/R/size.R index ce245f7..001817b 100644 --- a/R/size.R +++ b/R/size.R @@ -7,8 +7,16 @@ #' default behavior is more reasonable in those cases (i.e., returning NA), #' but since the point of this function is to replicate MATLAB behaviors #' (bugs and questionable behaviors included), this function also does this. +#' @export size <- function(x, d) { # Determining the number of dimensions + if (all(is.na(x))) { + if (missing(d)) { + return(c(0, 0)) + } else { + return(ifelse(d <= 2, 0, 1)) + } + } if (length(x) == 1) { # x is surely a scalar return(1)