Related Articles

Related Articles

Check whether a value is logical or not in R Programming – is.logical() Function
  • Last Updated : 16 Jun, 2020

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

Syntax: is.logical(x)

Parameters:
x: Value to be checked

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R Program to test whether
# a value is logical or not
  
# Calling is.logical() function
is.logical(0)
is.logical(!5)
is.logical(T)
is.logical(FALSE)

chevron_right


Output:

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

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R Program to test whether
# a value is logical or not
  
# Creating vector
x1 <- c(1, 2, 3, 4)
x2 <- c(T, F, TRUE, FALSE, ! 2)
x3 <- c(1, T, F)
  
# Calling is.logical() function
is.logical(x1)
is.logical(x2)
is.logical(x3)

chevron_right


Output:

[1] FALSE
[1] TRUE
[1] FALSE
My Personal Notes arrow_drop_up
Recommended Articles
Page :