Session Ready
Exercise

%in%

If rather than an index we want a logical that tells us whether or not each element of a first vector is in a second, we can use the function %in%. For example:

x <- c(2, 3, 5)
y <- c(1, 2, 3, 4)
x%in%y

Gives us two TRUE followed by a FALSE because 2 and 3 are in y but 5 is not.

Instructions
100 XP

Which of the following are actual abbreviations: MA, ME, MI, MO, MU?

  • Define a character vector with the abbreviations MA, ME, MI, MO, MU.
  • Use the %in% operator to create a logical vector that is TRUE when the abbreviation is in murders$abb.