foo <- function(arg1, this, that) { if (missing(this) && !missing(that)) this <- that if(this < 0) stop("this must be positive") return(arg1/this) } foo(arg1=5, this=10) foo(arg1=5, that=10)