Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Text values
Variables
Functions
20. Function result as a variable
Summary

Instruction

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).

Exercise

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