MulaiMulai sekarang secara gratis

Combining i, j, and by (I)

In this exercise, you will combine the i, j, and by arguments to find the first and last ride for each start station. Recall that data.table first filters the rows in i, and then groups the rows using by, and finally compute the expression in j.

Latihan ini adalah bagian dari kursus

Data Manipulation with data.table in R

Lihat Kursus

Petunjuk latihan

  • Arrange batrips using the start_date column in ascending order.
  • Group the rows by start_station.
  • Extract the first and last rows of start_date.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Find the first and last ride for each start_station
first_last <- batrips[___, 
                      .(start_date = ___), 
                      by = ___]
first_last
Edit dan Jalankan Kode