Returning Several Values
Return a list to give back several values.
Example
stats <- function(x) list(min = min(x), max = max(x), mean = mean(x))
r <- stats(c(3, 1, 4, 1, 5))
print(r$max)
print(r)Exercise
Return many.
(a = 1, b = 2)Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.