Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Key elements of the visualization process
Environment - the R Language
11. Working with R

Instruction

Let's learn some basic commands in R. We'll use them later in our course.

The simplest thing in R is to create a variable and save it. Imagine that you work in the zoo and you want to record how many lions are in the zoo. To do that, you go to the lion enclosure and count them: there are five lions. To save this information in R, you type the following:

lions <- 5

The <- is the assignment operator: it assigns everything that is on its right to variable placed on its left. Here we assign the number 5 to the variable called lions.

To call this new variable and check whether it was properly saved, just type its name, lions, in the next line:

lions

Exercise

You counted three elephants in the zoo. Assign this number to a new variable named elephants.

When you're done, press the Run and Check Code button.

Stuck? Here's a hint!

You should write:

elephants <- 3