Basic data types in R
R works with numerous data types. Some of the most basic types to get started are:
- Decimal values like
4.5
are called numerics. - Whole numbers like
4
are called integers. Integers are also numerics. - Boolean values (
TRUE
orFALSE
) are called logical. - Text (or string) values are called characters.
Note how the quotation marks in the editor indicate that "some text"
is a string.
This is a part of the course
“Introduction to R”
Exercise instructions
Change the value of the:
my_numeric
variable to42
.my_character
variable to"universe"
. Note that the quotation marks indicate that"universe"
is a character.my_logical
variable toFALSE
.
Note that R is case sensitive!
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Change my_numeric to be 42
my_numeric <- 42.5
# Change my_character to be "universe"
my_character <- "some text"
# Change my_logical to be FALSE
my_logical <- TRUE