Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Text values
Variables
9. Value names
Functions
Summary

Instruction

Perfect! It's time to move on to other topics that will allow us to be more flexible in our coding. Like other programming languages, R allows you to assign names to your values. This allows you to reuse the values in your code instead of having to hard-code the values again.

Such a name is called a variable. If your variable is named weight, you can retrieve its value by simply typing its name, like so:

weight

R will return the value stored by the variable under this name. Note that you don't need quotation marks to retrieve the value of a variable.

Exercise

We have created a height variable that represents John's height (in centimeters). Retrieve the value of that variable.