Apologies for the lack of clarity. I meant is there an inbuilt function that would take any fraction, and return the appropriate number? (not just 50%)

Genralise median to quantile, and it'll solve your question.

lerp <- function(num1, num2, fraction){
(num2-num1)*fraction+num1
}
for (i in seq(0, 1, 0.01))
{
a <- lerp(10, 20, i)
b <- quantile(c(10, 20), i)
if (isFALSE(all.equal(a, b))) {
print(c(i, a, b))
}
}

But nothing's wrong your function, as far as I can see. You can continue to use that as well.