R – NOT Logical Operator
R – NOT Operator !
is used to perform logical NOT operation on the given boolean operand.
!
symbol is used for Logical NOT Operator in R Language.
NOT Operator takes a boolean value as operand on its right and returns the logical NOT of the given operand.
The syntax of NOT Operator with a boolean operand is
!operand
Truth Table
The following truth table provides the output of NOT Operator for different values of operands.
operand | ! operand |
---|---|
TRUE | FALSE |
FALSE | TRUE |
NOT Operation returns TRUE if given operand is TRUE, or FALSE if the given operand is TRUE.
Example
In the following R program, we will take different boolean values for an operand and find the result of NOT operation on the given operand.
example.r
x <- TRUE
result <- !x
cat("!", x, " is ", result, "\n")
x <- FALSE
result <- !x
cat("!", x, " is ", result, "\n")
Output
tutorialkart$ Rscript example.r
! TRUE is FALSE
! FALSE is TRUE
Conclusion
Concluding this R Tutorial, we learned what R Logical NOT Operator is, and the output of NOT Operation for different boolean values as operand, with the help of an example program.