Session Ready
Exercise

Filtering rows using negative integers

Sometimes, instead of selecting all of the rows you want individually, it makes sense to deselect the rows you do not want to include. Recall that this can be done using either the ! or the - operators.

For example, dt[-(1:5)] returns all rows except the first five.

Note: dt[-(1:5)] is equivalent to dt[!(1:5)].

Instructions 1/3
undefined XP
  • 1

    Use negative indexing to exclude the first two rows in batrips.

    • 2

      Use negative indexing to exclude rows 1 through 5 and 10 through 15 in batrips.

    • 3

      Use negative indexing to exclude the first and last rows in batrips.