Select, for columns Filter, for rows Mutate, for adding rows or changing values
On top of that there are a bunch of sugared versions of these, like rename, instead of select or transmute instead of mutate.
When you want to do something advanced you either combine those or go out to see if somebody else has already made that function for you. I don’t think that having functions for joins or removing NA’s is something special to tidyverse. Everybody needs to put such operations somewhere.
I find tidyverse to have a simple, expandable vocabulary that is easy to learn, read and grow.
But it is slow.
I never found any kind of logic behind data.tables API, and I find it hard to read. I haven’t found an introduction to it that makes anything click.
But it is fast and it has these absolutely amazing rolling joins
This is how I learned dt.
How does selecting the 3rd column,
dt[, 3]
jive with>`DT[i, j, by, ...]` which means: “Take DT, subset rows using i, then calculate j ...
I don’t understand how column selection and calculating an expression is the same thing.
So now I can’t figure out if
DT[, sum(V1)]
Will return the column indexed at the sum of V1 or if it will return the sum of the column called V1. How can I tell, from the syntax?So for your first example it grabs the third column. The calculation you’re performing is a column selection.
For your second example, you’re returning all the rows, selecting column V1, and summing it.
I really prefer to name the operations
dt[rows, columns, groups]