Skip to content

Commit 3e57458

Browse files
committed
add obvious stop
1 parent 44af93c commit 3e57458

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

R/summary_functions.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ bias <- function(estimate, parameter = NULL, type = 'bias', abs = FALSE,
121121
stopifnot(is.matrix(estimate))
122122
stopifnot(type %in% c('bias', 'standardized', 'relative', 'abs_relative'))
123123
n_col <- ncol(estimate)
124-
if(type == "relative") stopifnot(!is.null(parameter))
124+
if(type %in% c("relative", 'abs_relative')){
125+
stopifnot(!is.null(parameter))
126+
if(any(parameter == 0))
127+
stop('relative measures cannot have any parameter = 0', call.=FALSE)
128+
}
125129
if(is.null(parameter)) parameter <- 0
126130
if(is.data.frame(parameter)) parameter <- unlist(parameter)
127131
stopifnot(is.vector(parameter))

0 commit comments

Comments
 (0)