Home » R Datatypes

Data Types in R Programming

In programming languages, we need to use various variables to store various information. Variables are the reserved memory location to store values. As we create a variable in our program, some space is reserved in memory.

In R, there are several data types such as integer, string, etc. The operating system allocates memory based on the data type of the variable and decides what can be stored in the reserved memory.

There are the following data types which are used in R programming:

R Programming Data Types

Data type Example Description
Logical True, False It is a special data type for data with only two possible values which can be construed as true/false.
Numeric 12,32,112,5432 Decimal value is called numeric in R, and it is the default computational data type.
Integer 3L, 66L, 2346L Here, L tells R to store the value as an integer,
Complex Z=1+2i, t=7+3i A complex value in R is defined as the pure imaginary value i.
Character ‘a’, ‘”good'”, “TRUE”, ‘35.4’ In R programming, a character is used to represent string values. We convert objects into character values with the help ofas.character() function.
Raw A raw data type is used to holds raw bytes.

Let’s see an example for better understanding of data types:

When we execute the following program, it will give us the following output:

R Programming Data Types


Next TopicR Data Structures

You may also like