MulaiMulai sekarang secara gratis

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)].

Latihan ini adalah bagian dari kursus

Data Manipulation with data.table in R

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Select all rows except the first two
not_first_two <- ___
not_first_two
Edit dan Jalankan Kode