Selecting multiple elements with [

NA values in the selection vector (indices, logical) are returned as NA

This is different to:

  • dplyr::filter(df, df$x > 0) drops NA values
  • base R: which(<logical vector>) drops NA values
    • it filters a logical vector for TRUEs and returns their index, e.g. in which(x > 0)