Aan de slagGa gratis aan de slag

Equality

The most basic form of comparison is equality. Let's briefly recap its syntax. The following statements all evaluate to TRUE (feel free to try them out in the console).

3 == (2 + 1)
"intermediate" != "r"
TRUE != FALSE
"Rchitect" != "rchitect"

Notice from the last expression that R is case sensitive: "R" is not equal to "r". Keep this in mind when solving the exercises in this chapter!

Deze oefening maakt deel uit van de cursus

Intermediate R

Cursus bekijken

Oefeninstructies

  • In the editor on the right, write R code to see if TRUE equals FALSE.
  • Likewise, check if -6 * 14 is not equal to 17 - 101.
  • Next up: comparison of character strings. Ask R whether the strings "useR" and "user" are equal.
  • Finally, find out what happens if you compare logicals to numerics: are TRUE and 1 equal?

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Comparison of logicals


# Comparison of numerics


# Comparison of character strings


# Compare a logical with a numeric
Code bewerken en uitvoeren