Some thoughts on teaching R for the first time

First, some context about the course. This year our psychology MRes programme made the switch from teaching stats in SPSS to R. There are two weeks of “Intro to R” classes that cover the basics (data processing, descriptive statistics, intro to ggplot). In each week there is a “lecture” on Wednesday and a “workshop” on Friday for which they must complete some preparatory work (based around the brilliant R for Data Science). There’s then a break for a few weeks whilst they have other intro classes (e.g., Matlab) and then they’re going to come back and do their stats classes. I have been largely responsible for the Intro to R classes and that’s what this blog is about – getting them into the basics, rather than actual stats.

Second, some context about me. I’ve been very slowly teaching myself R for the last 2-3 years. I’m not the most confident user (although from what I see on Twitter I think this is the default state of being), my code tends to be functional rather than elegant or efficient, and I still constantly have to Google everything I do (again, from what I see this seems to be the default but imposter syndrome is strong and mighty and knows no logic). Basically, if you're reading this and you think I don't know what I'm talking about, then please feel free to tell me and give me suggestions (contacts details here or feel free to comment or tweet) but please don't be a dick about it.

1. Ensure that you have the right software (i.e., updated R/R Studio) installed on all the computers you will need for teaching. This might seem so obvious as to be a waste of words, something akin to “make sure you turn the oven on”. But having arrived in the classroom to find that the chicken was still raw I can assure you that it’s worth your time and anxiety levels to double-check that these things are in place.

2. If your teaching timetable will allow it, don’t let them go in blind. The original plan was to spend most of the first lecture giving a guided tour to R Studio (scripts, the working environment, how to load packages, how to load data, R Markdown) and then they would go off and work through a few chapters of R for Data Science as preparation for the workshop which was focused on data processing/cleaning and descriptives using the tidyverse. Because of 1) the guided tour didn’t happen, so when they went to do the preparation work it was the first time they’d seen R in action, and this caused some anxiety and some issues. In the second week, they were totally fine. Essentially, if you’re teaching a group of students who have had absolutely no experience of programming or R, then I would highly recommend ensuring that their first time isn’t a solo experience.

3. Don’t introduce R Markdown straight away. For the preparation work they had to use Markdown to submit their answers. Now, this is a fantastic idea in principle but it introduces several other variables into the mix that can go wrong – knitting files not working etc. - that I think are best to avoid whilst they’re getting to grips with all the other stuff that’s completely new. Next year, I’ll introduce Markdown after the intro classes, perhaps as part of the stats classes when they’ve got some results to communicate.

4. “It’s just so different to what I’ve been used to”. This was by far the most common feedback and I think the real crux of the difficulties they encountered. Now obviously there’s not much you can do about this when you’re teaching postgrads. Things are slowly changing but chances are that what they’re used to is SPSS. I’ve got no useful advice for how to get round this for postgrads but I just want to make the point that many people baulk at the idea of teaching R to undergrads yet if the main problem with learning R is that it’s so different to what they’re used to….the most logical solution is to teach it before they’ve gotten used to anything else.

5. Manage your anxiety as well as your students’. This is likely to depend on who is doing the teaching but the first week I was probably more anxious than my students (which then made things worse) especially after seeing the pain of the first preparation exercises (see 1) 2) 3)) but once we got past that they were fine. Totally fine and happy and making pretty graphs in ggplot2 with no problem. Next year I will try to remember that no matter how fraught they seem in the first week, it doesn’t last for long.

6. Explain that when it comes to R, many functions lead to Rome and show them examples of different packages and functions that do the same thing. Others disagreed with me on this and said that for the intro classes it was best to provide concrete solutions and have one way of doing things. I can see the logic of this and it may well be right, but I would argue that both the beauty and pain of R is its flexibility and it’s important to understand this straight away – if nothing else for when you inevitably end up on stackoverflow it’s good to know there’s potentially a straightforward reason your code looks nothing like the solution. 

That's it so far. This blog took so long to write that the stats classes start in just over a week so there may be more soon!


Comments

Popular Posts