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


Now you know how to assign a value to a variable. Let's find out what we can assign to variables – in other words, the R data types.

In R, there are four main data types:

  • Numbers;
  • Strings;
  • Logical values;
  • Factors;

Let's consider the first two types. The first type, numbers, holds numbers in every form. We've already used 5 and 3, but we could just as easily have used 5.5 and 3.239074 (except, of course, that we would never find half or even .239074 of an animal in a zoo!)

The second data type is strings. This stores text, like "lions", "elephant", and "You're awesome". Think of it as a name or a word description of something.

Suppose you want to save the name of your favorite lion, Elsa. You would insert this text in quotes. You can use either double quotes (") or single quotes ('), but use the same at the beginning and end of the text. You would use the same operator to assign the value to a variable, like this:

my_lion <- "Elsa"


Your favorite elephant's name is Booboo. Save the elephant's name to the new my_elephant variable.

When you're done, press Run and Check Code to check your code.

Stuck? Here's a hint!

You should write:

my_elephant <- "Booboo"