LoslegenKostenlos loslegen

Selecting columns by name

DT[, c("col1", "col2")] returns a data.table with two columns, just like a data.frame.

Alternatively, you can also select columns by passing a list with each element referring to the column name as if it were a variable, i.e., DT[, .(col1, col2)]. Note the absence of quotes, i.e., "" around column names here.

Diese Übung ist Teil des Kurses

Data Manipulation with data.table in R

Kurs anzeigen

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Select bike_id and trip_id using a character vector
df_way <- batrips[___]
df_way
Code bearbeiten und ausführen