ourMELONS/R/nargin.R

11 lines
425 B
R
Raw Normal View History

2020-10-19 08:44:10 +02:00
#' @title Number of function input arguments
#' @description Returns the number of arguments passed to the parent function
#' @return An integer
#' @author Waldir Leoncio
#' @note This function only makes sense inside another function
2020-10-19 09:49:30 +02:00
#' @references https://stackoverflow.com/q/64422780/1169233
2020-10-19 08:44:10 +02:00
nargin <- function() {
2020-10-19 09:49:30 +02:00
if(sys.nframe() < 2) stop("must be called from inside a function")
length(as.list(sys.call(-1))) - 1
}