Count rows kept by a two-condition filter

A sales manager keeps the following data frame of representatives in R and wants to count the West-region representatives who sold at least 10 units.


R
sales <- data.frame(
  rep = c("Ali", "Bea", "Cy", "Dan", "Eve", "Fay", "Gus", "Hal"),
  region = c("West", "East", "West", "West", "North", "West", "East", "West"),
  units = c(12, 15, 8, 10, 20, 25, 9, 10)
)
nrow(sales[sales[, "region"] == "West" & sales[, "units"] >= 10, ])


What number does the last line print? Give your answer as a whole number.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More R Data Frames Questions: