Recall & Review
beginner
What is a return value in R functions?
A return value is the result that a function sends back after it finishes running. It is what you get when you call the function.
Click to reveal answer
beginner
How do you explicitly return a value from a function in R?
You use the
return() function inside your function to send back a specific value.Click to reveal answer
beginner
What happens if you do not use
return() in an R function?R automatically returns the last evaluated expression in the function, even if you don't use
return().Click to reveal answer
intermediate
Can a function in R return multiple values?
Yes, by returning a list or other data structure, a function can return multiple values at once.
Click to reveal answer
beginner
What is the difference between
print() and returning a value in R?print() shows output on the screen but does not send a value back from the function. Returning a value allows other code to use that result.Click to reveal answer
What does the
return() function do in R?✗ Incorrect
return() sends a value back from a function to where it was called.
If a function in R does not have a
return() statement, what happens?✗ Incorrect
R automatically returns the last evaluated expression if return() is not used.
How can a function return multiple values in R?
✗ Incorrect
Returning a list lets a function send back multiple values together.
Which of these is NOT true about return values in R?
✗ Incorrect
Return values are not printed automatically; you must print them if you want to see them.
What is the main difference between
print() and returning a value?✗ Incorrect
print() displays output on screen; returning sends a value back for further use.
Explain what a return value is in R and how it is used in functions.
Think about what happens after a function finishes running.
You got /3 concepts.
Describe how you can return multiple values from a single R function.
Consider how to package several things together.
You got /3 concepts.