Open In App

Check if a value or a logical expression is TRUE in R Programming – isTRUE() Function

Last Updated : 16 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

isTRUE() function in R Language is used to check whether a value or a logical expression is true or not.

Syntax: isTRUE(x)

Parameters:
x: logical or number-like vector

Example 1:




# R Program to test whether
# an expression is TRUE
  
# Calling isTRUE() Function
isTRUE(1)
isTRUE(1>0)
isTRUE("a")


Output:

[1] FALSE
[1] TRUE
[1] FALSE

Example 2:




# R Program to test whether
# an expression is TRUE
  
# Creating vectors
x <- c(1, 2)
y <- c(4, 5, 6, 7)
  
# Calling isTRUE() Function
isTRUE(x < y)
isTRUE(x && y)
isTRUE(x || y)


Output:

[1] FALSE
[1] TRUE
[1] TRUE

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads