I have been writing the last several weeks about how I teach coding in a non-coding focused class. Last week I discussed setting up for live coding. This week I’m writing about nuts and bolts. How do I get students the code, what do we do in class, how do you like… do it.
First: Get everyone set up and ready.
My early attempts at live coding were mired in issues with file paths, incompatible versions of software and packages,etc. Most time consuming and taxing was the file path stuff. Many of today’s students have never seen a text file path, in my experience. It makes sense, in nearly all ways you interact with technology these days, it is not something you encounter. The other issue was just running specific lines of code. For whatever reason, the link between writing in a file and then putting it in the console or selecting and running it was always problematic for some students to wrap their head around.
Enter: R Projects and notebooks. In Posit Studio (R studio) you can create what they call a project by clicking file>new project. The folder you put your new project in will have a file with a .rproj extension. When you open that file, it opens an instance of Posit Studio where the working directory IS the folder your .rproj is in. This was a game changer for teaching. I can send students a zipped R project, and when they open it up, they only need to type relative directories to that folder for reading/writing data. Gone are the days of trying to figure out the path to a student’s file when they don’t even know where it is on their computer.
Just be sure you say somewhere between 10 and 30 times at the beginning of the semester that you need to open the .rproj file and not the code file!
Then, in that R project folder I put R markdown or Quarto notebooks. These notebooks allow you to have sections of word processor-like text with “chunks” of code in between. You can write code in those chunks and then click a little “play” button to run JUST the code in that chunk. I find students find this much more intuitive.
You can see an example of what the output of these notebooks looks like here: https://vt-hydroinformatics.github.io/Quarto_Book/01-Plotting_Demo_COMPLETE.html
And at this github repository, you can check out or download what the companion course notes look like. Students would go to this page, click the “code” button, download the zip, uncompress it, open the folder, and click the .rproj folder. https://github.com/VT-Hydroinformatics/1-Intro-plotting-R
Quick note: Windows is happy to let you open a zipped folder and open files within it keeping in compressed. This causes a world of pain in Rstudio/posit cloud projects. Tell students 10 to 30 times to be sure to unzip the folder before starting!
I put two notebooks in the folder for a topic of the course. They are basically notes for that day in class with chunks of code interspersed. They are identical except that in one, all the code chunks are empty and in the other they have all the necessary code. The completed version is there for students in case they miss class or get really sideways during class and need to get back on track. The consequences of missing class or getting really behind without the completed notes would be too harsh and I think cause students who are less comfortable asking for help disengage.
So, in class the students open the project and the empty notebook file. I project my screen with the exact same file open. I capture and record my screen and my voice using zoom to post after class. I have an ipad next to me with the completed notes that I can reference as I go. I’ve also done this with printed notes in the past. More details about this setup are in last week's post.
Then we are off to the races. The text between the chunks has figures and illustrations, which I use to discuss concepts, and then we code. I type the code as I describe what I am doing. If it’s something similar to what we’ve done before, I might ask the class to take a couple of minutes to try it before I type. Interspersed through the document I have “challenges” where I ask students to complete a small task on their own. I often start class with a challenge: either a multiple choice quiz (which of these lines has/doesn’t have an error, for example) or a small coding task that they turn in (write one line of code that makes a plot that…). This is some nice structured retrieval practice that I think really benefits the students.
All activities and tests in the class are in similar notebooks. Students can “render” or “knit” the notebooks into a pdf or html and then submit on canvas. The output is a nice document with the notes or questions and then the students’ code and its output. I find these to be pretty easy to grade. For the first couple of weeks I ask students to turn in their rendered notes, to be sure they are keeping up and everything is running well on their computer.
I was going to discuss how I talk and write code once everything is up and running, but I think that will result in too long a post! So I am going to save that for next week.