4 ms·
I teach a data science graduate course to non-tech majors, and it's mostly on R. I welcome these changes. I teach base R first for a few weeks, then I teach th
by AuthorizedCust 7y ago
I teach a data science graduate course to non-tech majors, and it's mostly on R. I welcome these changes.
I teach base R first for a few weeks, then I teach the TidyVerse as I introduce data science concepts, like text mining. I convey the TidyVerse as like an overlay on R, improving shortcomings and adding great functionality, syntactic sugar, etc.
This context switch is jarring to some students. It's great to see some of the TidyVerse's strengths--part of the tibble--be moved back into base R.
Now pardon me: I need to go. I start teaching dplyr in 51 minutes!
- ianbooker 7y agoThanks for sharing. I do exactly the same, and I always find it hard to justify base-R in front of my students, after they learn about the Tidyverse ;)
- deleted 6y ago[deleted]
- acomjean 6y agoThanks too. I had not heard of the "TidyVerse". The TidyVerse is a opinionated group of R packages that all function similarly. ggplot2 is in there, and I already use that one. I do like R for analysis. (I choose to use it over excel or Stata for my data analysis/ classes), though I wish the help pages were better. Its a hard language to grok, even the data type names are unclear (data frame, vs matrix, vs vectors..). I'll take a look at the tidyverse packages. https://www.tidyverse.org/learn/ https://www.tidyverse.org/learn/ any additional learning resources you'd recommend?
- wodenokoto 6y agoThe “R for Data Science” book by Hadley Wickham (creator of tidyverse, and I believe he is chief data scientist at R Studio) is hands down one of the best introductions to data exploration and analysis.
- bart_spoon 6y agoAs the other commenter said, probably the best resource out there is "R for Data Science" by Hadley Wickham, the architect of the tidyverse. It will get you up and running with the most important parts of the tidyverse (dplyr for data manipulation, ggplot2 for data visualization, tidyr for general data cleaning utilities, etc). Its available online for free here: https://r4ds.had.co.nz/ https://r4ds.had.co.nz/
- Eugeleo 6y agoTo add onto others’ answers, Advanced R from the same author dives more into the inner wirkings of R (such as lists X vectors, what are classes etc). It helped me understand why my code works the way it does.
- clircle 6y agoI 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 6y 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 6y agodon't forget the crucial group_by() / summarise()
- nojito 6y 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 6y 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?
- phillc73 6y agoI must admit to not really understanding the TidyVerse attraction, or why I should be doing "tidy data evaluation", rather than using base R. If I want to use an advanced data manipulation library, I'd typically reach for data.table. If I want to use a verb based approach, why not SQL rather than dplyr. I have tried dplyr and code I've written a few years ago still imports that package (hopefully it still works), but I just didn't find it was particularly useful or helpful compared to the alternatives.
- ebb_earl_co 6y agoI studied statistics, so R was the first programming I ever learned. I didn't know what it was at the time, but the tidyverse's chaining of operations on a data frame (via magrittr's %>%) was a really cool introduction to functional programming
- phillc73 6y agoThe pipe operator in R also sort of does my head in. I learned R in a way that everything went right to left. The variable on the left was manipulated by whatever (functions or other code) on the right. The pipe operator reverses that flow, with everything now moving left to right, which I find difficult to follow and debug.
- laGrenouille 6y agoThe best use of the pipe operator, in my opinion, is when every pipe followed by an end line, like this: data %>% filter(thing > 4) %>% mutate(new = fun(old)) %>% group_by(var) %>% summarize(new_mean = mean(new)) Then you are reading the code top-to-bottom, just like any other R script but without all of the temporary variables.
- disgruntledphd2 6y agoThis only really works if nothing ever fails. It's great for data analysis and terrible for programming. The reason it sucks for programming is because you can't debug it or inspect intermediate variables, which is really really annoying. It's great for one off transformations and plotting, but a really, really really bad idea for programming. Then you add NSE, which makes it hard to functionalise procedural pipes (especially for people who learned tidyverse) and it's a recipe for unmaintainable and profoundly annoying legacy code. That bring said,I love it for interactive analysis.