While this is a broad question, if someone is new to R
this can be confusing and the distinction can get lost.
All data.table
s are also data.frame
s. Loosely speaking, you can think of data.tables as data.frames with extra features.
data.frame
is part of base R
.
data.table
is a package that extends data.frames
. Two of its most notable features are speed and cleaner syntax.
However, that syntax sugar is different from the standard R syntax for data.frame while being hard for the untrained eye to distinguish at a glance. Therefore, if you read a code snippet and there is no other context to indicate you are working with data.tables and try to apply the code to a data.frame it may fail or produce unexpected results. (a clear giveaway that you are working with d.t's, besides the library
/require
call is the presence of the assignment operator :=
which is unique to d.t)
With all that being said, I think it is hard to actually appreciate the beauty of data.table
without experiencing the shortcomings of data.frame
. (for example, see the first 3 bullet points of @eddi's answer). In other words, I would very much suggest learning how to work with and manipulate data.frames
first then move on to data.table
s.