To copy a data.frame as a data.table, use
DF = data.frame(x = letters[1:5], y = 1:5, z = (1:5) > 3) DT <- as.data.table(DF) # or DT <- data.table(DF)
This is rarely necessary. One exception is when using built-in datasets like
mtcars, which must be copied since they cannot be modified in-place.