Missings :
A missing value is one whose value is unknown. Missing values in R represented by NA symbol. NA is reserved word in R . We cannot use NA for give name of an object.
We can store missing value NA in an object :
We can combine NA with other values :
We can combine character object with NA :
Here “NA” is a character value while NA is missing.
We can also create NA in logical as:
Logical Operators :
And operator (&) :
When both conditions are TRUE then output is TRUE.
Truth Table of AND operator is :
Input 1 |
Input 2 |
Output |
TRUE |
FALSE |
FALSE |
FALSE |
TRUE |
FALSE |
TRUE |
TRUE |
TRUE |
FALSE |
FALSE |
FALSE |
u<-TRUE
v<-FALSE
u&v
Output :
[1] FALSE
First condition is TRUE and second condition is TRUE . From truth table output is TRUE .
(2 > 1)&(3==3)
Output :
[1] TRUE
OR operator (|) :
When one or both conditions are TRUE then output is TRUE.
Truth Table of OR operator is :
Input 1 |
Input 2 |
Output |
TRUE |
FALSE |
TRUE |
FALSE |
TRUE |
TRUE |
TRUE |
TRUE |
TRUE |
FALSE |
FALSE |
FALSE |
u<-TRUE
v<-FALSE
u|v
Output :
[1] TRUE
First condition is TRUE and second condition is FALSE . From , truth table output is TRUE.
(2 >1)|(3>4)
Output :
[1] TRUE
Not operator(!) :
This operator is used to negate the value. We negate “u” object value to FALSE.
u<-TRUE
Arithmetic operator :
The operator is used for mathematics calculation.
We can sum two objects by using “+” operator.
We can subtract objects by using “-” operator.
v <- c( 3,6.2,7)
t <- c(8, 3, 4)
v-t
Output :
We can multiply two objects by using “*” operator.
v*t
We can divide objects by using “/” operator.
We can find remainder by using “%%” operator.
We can find quotient of division by using “%/%” operator .
We can find exponential degree of values by using “^” operator.
v <- c( 2,3,6)
t <- c(5, 4,4)
v^t
Output :
Miscellaneous Operators :
Colon Operator (:)
It creates a series of numbers in sequence of values .
v<-20:30
v
Output :
%in% Operator
This operator is used to identify if an element belongs to an object .
W