Aan de slagGa gratis aan de slag

Adding a new column

As mentioned in the video, data.table does not have to deep copy objects in order to modify them. It can modify objects by reference (inplace) to save memory and runtime using the := operator. When you update a data.table by reference, you don't have to assign the result to a new object as the original data.table is modified directly.

Deze oefening maakt deel uit van de cursus

Data Manipulation with data.table in R

Cursus bekijken

Oefeninstructies

Add a new column duration_hour to batrips by reference, by dividing the duration column by 3600.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Add a new column, duration_hour
___[, ___ := ___]
Code bewerken en uitvoeren