Similar to what I wrote in my post about how I got into people analytics, I don’t really know what to tell people who ask about good ways to learn R. What I can do is share how I did it.
Early programming exposure
As a math/econ major in undergrad I didn’t appreciate how valuable programming could be. But an introductory JavaScript course was a requirement, and a 200-level C++ course would double count for graduation requirements, so I got exposed to a few principles. I’m glad I don’t have to program a linked list anymore. My economics classes also required me to use Stata, which I like to think of as what you’d get if all you ever wanted to do in R was run every kind of regression you could imagine. The syntax for a linear regression is literally
regress y x
which is kind of beautiful in its simplicity.
Anyway, I can’t pretend I hadn’t had any exposure to programming when I was first introduced to R. But I wasn’t actually competent in another programming language first.
Learning about R
I first heard of R when I did a month-long internship during winter break in grad school. I was supposed to look for patterns in email marketing data, and I needed to do it in R. I convinced the hiring panel that I was a quick learner and on my first day I was given a skeleton script that showed me how to load a dataset, and I think an example in ggplot2.
My memory is foggy at this point, but I remember using Swirl, DataCamp’s free courses, and of course Stack Overflow — anything I could find that was free. Eventually I made it through that internship and felt like I could at least do basic things.
Using R everywhere
The next step for me was to use R for anything that I might normally do in Excel. I was lucky here as well that I had almost never used Excel in my undergrad, so forcing myself to run summary stats or whatever simple analysis I had to do in my grad program was easy enough to do in R instead.
I think this is a really important point. I definitely took some courses, but I think where I learned R was by just using it a lot. Need to transpose that matrix in Excel? Off to figure out how to do that in R. Need to make a line graph? Nope, not going to do it in Excel, let’s read the ggplot cookbook or go back to Stack Overflow.
Hacking my HR degree
My next bit of luck was that my grad program allowed us something like six elective courses, and they did not care what those were. I used those to take three classes that used R. One was called Machine Learning and Data Mining (with R), which took my out of my comfort zone but again forced me to learn “on the job”. As an aside, without that course I wouldn’t be familiar with decision trees, splines, lasso or ridge regressions, or a number of other tools that I admit I don’t use very much, but that help me feel less clueless when I hear somebody else talk about them.
The other two classes were from a professor that I originally met when trying to figure out how to beef up the people analytics curriculum at my grad program. I didn’t have much luck there, but I found a professor who was willing to have me do a mostly self-guided course on people analytics and R. All I had to do was find a few willing classmates to join in so it wasn’t just me. Our textbook was Practical Data Science with R, which did a great job teaching analytical techniques and providing code examples that forced me to learn. To this day I find the authors’ blog a good recommendation for thinking about R (in particular, the posts on R pipes were particularly interesting for somebody who switched to the Tidyverse as quickly as I could).
Finally, I entered Wharton’s People Analytics Conference case competition, which was a great opportunity to work with some real world data from YearUp. Having a timeline and some competition was another good excuse to learn.
After school
From there I took jobs where I could use R at least sometimes. At my first job, I was on the sales team but the data science team used Python, so I made my way through the first part of a course but couldn’t make myself care enough to get good at it. I could already do everything I needed to do in R, so I couldn’t find the motivation.
It was really validating when DataCamp reached out to me and asked if I’d be willing to create a course for them on people analytics. Having somebody legitimately reviewing my code, and knowing how many people would see it, taught me a lot about testing, commenting, and being thoughtful about which functions to use. For anybody curious, I am aware of the scandal at DataCamp and how that was handled. I had already created my course before that story broke, and if there is another site that works for learning R, I encourage people to try it out.
Additional resources
I don’t get to use my programming skills as often as I used to in my current job, so I’m probably a little out of date. Here is a list of resources I have found useful.
Hadley Wickham’s R for Data Science is a joy to read. I love that it has exercises that made me think critically about what I’d just read. His Advanced R book is also valuable, especially for helping me really understand what’s going on under the hood. It was in one of these books, I think, that I learned the difference between `<-` and `<<-`. And other, more useful things.
The R Inferno is apparently 10 years old now so I have no idea how much is still accurate, but I maintain that there are some things you can only learn by listening to somebody complain about that thing. For multiple chapters. I’m not saying I read the whole thing through.
I already mentioned Practical Data Science with R by Nina Zumel and John Mount. It is excellent.
It wouldn’t be my first recommendation, but I learned a whole lot about how R works (and how it breaks) by playing around on the Code Golf Stack Exchange and trying to shave bytes off my code. Did you know that `(` is a function in R? What about `[`? Did you know you can assign them to other functions, like this? (I do not recommend this)
> `(` = mean
> (4:6)
[1] 5
> (1:10)
[1] 5.5
That’s my story. Learning R isn’t necessary for a career in people analytics but I’ve found it to be really helpful!