The subset function in R is used for multiple purposes such as:

  • Returning subsets of a vector, matrix, or data frame which meeting a particular condition
  • Selecting specific elements of a data structure.
BY Best Interview Question ON 14 Jul 2020