Variable assignment (2)
Suppose you have a fruit basket with five apples. As a data analyst in training, you want to store the number of apples in a variable with the name my_apples
.
This exercise is part of the course
Introduction to R
Exercise instructions
- Type the following code in the editor:
my_apples <- 5
. This will assign the value 5 tomy_apples
. - Type:
my_apples
below the second comment. This will print out the value ofmy_apples
. - Submit your answer, and look at the output: you see that the number 5 is printed. So R now links the variable
my_apples
to the value 5.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Assign the value 5 to the variable my_apples
# Print out the value of the variable my_apples