3 ms·
I find tidyverse a bit slow, and I don't like having to memorize all the verbs. I typically reach for data.table these days as a nice middle ground between base
by clircle 7y ago
I find tidyverse a bit slow, and I don't like having to memorize all the verbs. I typically reach for data.table these days as a nice middle ground between base R and tidyverse. Your thoughts?
- wodenokoto 7y agoThere’s like 3 verbs. 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
- kyllo 7y agodon't forget the crucial group_by() / summarise()
- nojito 7y agohttps://atrebas.github.io/post/2019-03-03-datatable-dplyr/#introduction https://atrebas.github.io/post/2019-03-03-datatable-dplyr/#i... This is how I learned dt.
- wodenokoto 7y agoThank you for the link. I still end up confused. 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?
- nojito 7y agoj is always for columns. 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]