Return Multiple Objects from User-Defined Function in R (Example) | Create List of Output Values

preview_player
Показать описание
R code of this video:

my_fun <- function(x) { # Create user-defined function

y <- x + 1 # Create two outputs within function
z <- x + 2

out <- list(y, z) # Store output in list
return(out) # Return output
}

my_output <- my_fun(5) # Apply function
my_output # Print two outputs to RStudio console

Follow me on Social Media:

Рекомендации по теме
join shbcf.ru