Close, then reopen your project from the earlier session
Pull to get any changes since you last worked on it
Create a new R script (.R)
Save your script as intro-logicals.R
2. Comparison operators
Comparison (or relational) operators compare values and return TRUE or FALSE depending on what you’re comparing.
Less than or greater than
2<4
[1] TRUE
5<2
[1] FALSE
"A"<"D"
[1] TRUE
"Z"<"Q"
[1] FALSE
"cat"<"dog"
[1] TRUE
"yeti"<"armadillo"
[1] FALSE
So we can see that values can be considered numerically or alphabetically.
This is also true for vectors - each element in a vector will be compared to the corresponding value in the other vector (i.e., the first element in a gets compared to the first element in b). Let’s make a couple vectors and try it out: