4 ms·
Idiomatic R has changed enormously with the growth of Magrittr the ℅>℅ operator, dplyr and now broom. Code by expert users is unrecognisable from that of a few
by Malarkey73 10y ago
Idiomatic R has changed enormously with the growth of Magrittr the ℅>℅ operator, dplyr and now broom. Code by expert users is unrecognisable from that of a few years ago.
- ekianjo 10y agoYeah but that tutorial does not even go into dplyr or tidyr.
- Malarkey73 10y agoIndeed - I think it's unclear how you should begin to teach R now. There is a lot of legacy stuff that you may need to recognise if you want to understand the help documentation. But if you wanted to seriously work in R it maybe better to skip straight to ggplot2, dplyr and broom without touching base R, the apply functions, and list in list in list hell.
- thenipper 10y agoThat's pretty much what I did. I dip back down into the 'base' stuff when I need to, but in general I stick in the hadleyverse of tools. It's been great.
- jghn 10y agoIndeed. 10-12 years ago there were probably no more than 50ish people in the world who knew R better than me. By 5 years ago the tide had heavily turned but I was still using it at least a few times a week. If I had to use R as a daily driver now it'd be like learning the language all over again. I could write it using the old ways, and u do that on the few occasions I have to, but it's no longer idiomatic at all
- nonbel 10y agoR still looks pretty much the same to me when I look at the code on kaggle, stack exchange, etc. Can you share where you have seen this expert R use and/or what use cases?
- minimaxir 10y agoMost modern R usage I've seen, even on Kaggle, has used margittr/dplyr since it's orders of magnitudes faster/easier than the base functions. (i.e. I almost quit R in favor for Python without those two) A quick example of my own notebook which uses margittr/dplyr heavily to process Stack Overflow survey data: https://github.com/minimaxir/stack-overflow-survey/blob/master/stack_overflow_dev_survey.ipynb https://github.com/minimaxir/stack-overflow-survey/blob/mast...
- nonbel 10y agoThanks for the example code, it actually has me wondering whether using the pipes has any impact on performance. They are much easier to read than the nested function calls that would be used instead. However, I mean I just searched for an R script on kaggle and the first I found is this: https://www.kaggle.com/bpavlyshenko/grupo-bimbo-inventory-demand/bimbo-xgboost-r-script-lb-0-457/output https://www.kaggle.com/bpavlyshenko/grupo-bimbo-inventory-de... From my experience that is a typical example (data.table is very common, but not so much dplyr and the pipes). I looked through the recent/featured questions on stack overflow and cross validated and saw only "old school" R as well. For example: http://stats.stackexchange.com/questions/228800/ http://stats.stackexchange.com/questions/228800/