I'm writing a package function that needs defaults parameters to work, but whose values have to be taken from processed (other) arguments of the function. As of now, I'm doing it like so :
myfunc <- function(x, y, n=NULL){
processed <- some_other_func(x,y)
x <- processed$x
y <- processed$y
if(is.null(n)){
n <- length(intersect(x,y))/3
}
# do stuff
}
But ideally, I'd like a default expression to be put instead of NULL
because it seems inconsistent if my doc says that the default is length(intersect(x,y))/3
.
Do you know of a way I could specify the default parameter to be more comprehensible ?