> names <- c("Scott", "Dave", "Lindsey", "Mackenzie")
> vals <- c(3, 0, 1, -2)
> min_score <- 1000
Comparison operators
This page contains much of the very fundamental information about R that you need to interpret and use it effectively. You should look through all of it now, but you will also benefit from periodically returning to this page as well—your increased understanding will enable you to gain more insights from all of this.
1 The operators
R accepts a set of comparison conditions:
x == y
: isx
equal toy
?;Race == "H"
x != y
: isx
not equal toy
?;St != "SC"
x >= y
: isx
greater than or equal toy
?;SAT >= 1000
x > y
: isx
greater thany
?;SAT > 1200
x <= y
: isx
less than or equal toy
?;SAT =< 1000
x < y
: isx
less thany
?;SAT < 1000
2 Examples
We are going to provide some examples of how to use the the comparison operators. First, let’s define a few variables that we will use in those examples:
Here are some examples of these simple arithmetic operators:
> 900 == min_score
1] FALSE
[> 900 >= min_score
1] FALSE
[> 900 <= min_score
1] TRUE [