1.6 Logical Vectors and Operators

In an earlier quiz you created a vector v3 of length 8. Compare each value in that vector to see if it is greater than 5 (you should end up with a vector of TRUE and FALSE).

v3 > 5


Extract a subset of the vector v3 that includes only the values greater than 5

v3[v3 > 5]


Compare each value in the "Petal.Length" of the (built-in) "iris" dataset to see which are greater than 5

iris$Petal.Length > 5


Extract the subset of rows from iris where Petal.Length is greater than 5

iris[iris$Petal.Length > 5, ]


Extract the subset of rows from iris where Petal.Length is greater than 5 and the Species is "versicolor"

iris[iris$Petal.Length > 5 & iris$Species == "versicolor", ]