What are the data types in r programming 

In the R programming language, there are several basic data types that are used to define the kind of data that can be stored in a variable, each with its own set of properties and operations:

Data Types in R programming

Numeric Data Type:

Represents a set of real numbers, including decimal values. In R, real numbers with a decimal point are represented using this numeric data type.


x <- 3.14
class(x) # Output: "numeric"
typeof(x) # Output: "double"

Integer Data Type:

  • Represents a set of all integers.
  • Integers are denoted by adding “L” at the end of the value.


y <- 42L
class(y) # Output: "integer"

Logical Data Type:

  • Represents logical (Boolean) values, which can be either TRUE or FALSE.


z <- TRUE
class(z) # Output: "logical"

Complex Data Type:

  • Represents a set of complex numbers with real and imaginary parts.


w <- 1 + 2i
class(w) # Output: "complex"

Character Data Type:

  • Represents a set of characters, including letters, digits, and special symbols, enclosed in double or single quotes.


str <- "Hello, World"
class(str) # Output: "character"

Raw Data Type:

  • Represents a single-byte memory containing raw data as bytes.


raw_value <- as.raw(255)
class(raw_value) # Output: "raw"

Each of these data types in R has its own specific operations and memory requirements, and they are crucial for effective memory consumption and precise computation in R programming.

Leave a Comment

Scroll to Top