Create a function with different arguments in R
问题 I am creating a function that does similar behavior but it would be calling different forecasting algorithms. modelBuild_auto_arima <- function(data, ...) { forecast::auto.arima(data) } modelBuild_ets <- function(data, model, ...) { forecast::ets(data, model = model) } ... Is it the best practice to keep it as separate functions and call it separately or create a generic function with "UseMethod". I tried creating with "UseMthod" modelBuild <- function(x, ...) { UseMethod("modelBuild") }