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

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

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

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

[1] FALSE
[1] TRUE
[1] TRUE
My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.