# R Data Types¶

Let's discuss some basic data types in R.

## Numerics¶

Decimal (floating point values) are part of the numeric class in R

In [1]:

    n <- 2.2

## Integers¶

Natural (whole) numbers are known as integers and are also part of the numeric class

In [3]:

    i <- 5

## Logical¶

Boolean values (True and False) are part of the logical class. In R these are written in All Caps.

In [5]:

    t <- TRUE
    f <- FALSE

In [6]:

    t

Out[6]:
TRUE
In [7]:

    f

Out[7]:
FALSE

## Characters¶

Text/string values are known as characters in R. You use quotation marks to create a text character string:

In [8]:

    char <- "Hello World!"

In [15]:

    char

Out[15]:
'Hello World!'
In [16]:

    # Also single quotes
    c <- 'Single Quote Char'

In [17]:

    c

Out[17]:
'Single Quote Char'

# Checking Data Type Classes¶

You can use the class() function to check the data type of a variable:

In [10]:

    class(t)

Out[10]:
'logical'
In [11]:

    class(f)

Out[11]:
'logical'
In [18]:

    class(char)

Out[18]:
'character'
In [19]:

    class(c)

Out[19]:
'character'
In [13]:

    class(n)

Out[13]:
'numeric'
In [14]:

    class(i)

Out[14]:
'numeric'

Those are some of the basic data types in R. Next we will learn about one of the main data building blocks of R, the vector!