:78 Function create_function() is deprecated [8192]
Filename | |
---|---|
plottingTools.R |
diff --git a/plottingTools.R b/plottingTools.R index 6766e99..c7411bb 100644 --- a/plottingTools.R +++ b/plottingTools.R @@ -7,15 +7,32 @@ # function to generate a semi-log plot of two vectors with connecting lines plotMC <- function(NS,probs, wHist=T) { - # obtain lenght of vectors + # DEFENSE ... DEFENSE ... + # this internal fn takes care of protecting the fn for receiving the proper arguments + defense <- function(input1,input2) { + # check that the arguments are vectors, ie. not a list! + if ( (class(input1) == "list") | (class(input2) == "list") ) { + stop("The fn requires two numeric vectors!") + } + + # check that the arguments are numbers! + if ( !is.numeric(input1) | !is.numeric(input2) ) { + stop("The fn requires two numeric vectors!") + } + + # check that the arguments have matching dimensions + if (length(input1) != length(input2)) { + stop("This function requires two vectors with the same number of elements!") + } + } + + # execute defensive programming first! + defense(NS,probs) + + # obtain lenght of vectors lNS <- length(NS) lprobs <- length(probs) - # check that the arguments have matching dimensions - if (lNS != lprobs) { - stop("This function requires two vectors with the same number of elements!") - } - # set up figure canvas par(fig = c(0,1,0,1))