On January 21th at 14:15 UTC , progression through exercises will be unavailable for 10 minutes due to a planned maintenance break.
Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Text values
20. Function result as a variable


Cool! As you may have already guessed, the result returned by a function can be assigned to a variable for use in further calculations.

For example, the result of round(182.5) can be saved in a variable named height, like so:

height <- round(182.5)

Just as before, assignment relies on the assignment operator (<-). When we type height later on in the editor, R will return the value 182 — the result of the earlier function call round(182.5).


Round John's current weight of 87.3 kilograms, and store it in a variable named weight.