My suggestion
I think the | 10 part is causing the issue, and since when logbase is 10, you get the same whether test evaluates to TRUE or FALSE, you can just remove it. I know you said in a comment this isn't working as expected, but it seems to for me - if it`s still not for you, feel free to comment.
fn1 <- function(x, logbase = NULL){
logbase <- ifelse(test = is.null(logbase), yes = 10, no = logbase)
out <- log(x = x, base = logbase)
return(out)
}
fn1(x = 10, logbase = NULL) # 1
fn1(x = 10, logbase = 2) # 3.321928
fn1(x = 10, logbase = exp(1)) # 2.302585
What the issue with your code was
The issue is anything with | 10 will always evaluate to TRUE. This is because the | operator will convert the arguments on both sides to logical, so something like is.null(2) | 10 is equivalent to as.logical(is.null(2)) | as.logical(10) which evaluates to F | T which is T.
To be clear, | 10 is not related to logbase. What you were looking for is presumably | logbase == 10. This is fine, except when logbase is NULL, you run into issues because NULL == 10 doesn't evaluate to T or F (it's logical(0)).
You can fix this by using ||, rather than |, which would only evaluate logbase == 10 if is.null(logbase) is FALSE, because if the first half of a || is TRUE, then it simply returns TRUE without evaluating the second half.