What is the is.atomic() function in R?

Overview

The is.atomic() function in R is used to check if an R object is atomic or not.

When an R object is atomic it can be used to create atomic vectors.

Note: R has six basic atomic vector types: logical, integer, real, complex, string (or character), and raw.

Syntax

is.atomic(x)
Syntax for the is.atomic() function in R

Parameter value

is.atomic(): The function takes a single parameter value x, which represents an R object, random or constant.

Return value

The is.atomic() function returns either TRUE or FALSE .

Example

# creating R objects
myname <- "Theophilus"
addition <- 5 + 3
numbers <- c(0:10)
a <- (quote(exp))
b <- expression(x+1)
# implementing the is.atomic() function
is.atomic(myname)
is.atomic(addition)
is.atomic(numbers)
is.atomic(a)
is.atomic(b)

Code explanation

  • Line 2–6: We create different R objects.
  • Line 10–14: We implement the is.atomic() function on the R objects to check if they are atomic or not.

Free Resources