background preloader

Teaching R

Facebook Twitter

How to Teach Programming (and Other Things): The Rules. It’s impossible to put everything that matters about teaching and learning on a single page, but these ten points are always worth remembering. Be kind: all else is details. Never teach alone. No lesson survives first contact with learners. Nobody will be more excited about the lesson than you are. Every lesson is too short from the teacher’s point of view and too long from the learner’s.

Never hesitate to sacrifice truth for clarity. Every mistake is a lesson. How to Teach R: Common mistakes – RStudio. By Garrett Grolemund Would you like to teach people to use R? If so, I would like to jump-start your efforts. I’m one half of RStudio’s education team, and I’ve taught thousands of people to use R, usually in face-to-face workshops. Over time, I’ve come to appreciate that teaching R in a short workshop is an unusual challenge that requires an unusual approach: you cannot teach a short workshop as if it were a college course, and you should not teach R as if it were Python, UNIX or C. In the next few blog posts, I’ll share what I’ve learned about teaching R workshops. We’ll begin in this post by identifying common mistakes that ensnare new R teachers. DO NOT teach R as if it were a programming language. I’ll have more to say about each of these topics in the posts that follow.

Latest teaching topics - RStudio Community. StatsTeachR. R for Excel users. Moving over to R (or any other programming language) from Excel can feel very daunting. One of the big stumbling blocks, in my view, is having a mental understanding of how we store data in structures in R. You can view your data structures in R, but unlike Excel where it’s in front of your face, it’s not always intuitive to the user just starting out. There’s lots of great information on the hows, whys and wherefores: here’s a basic rundown of some of the common ways we structure our data in R and how that compares to what you’re already familiar with: Excel. Homogeneous in this case just means all the ‘bits’ inside these structures need to be of the same type. There are many types of data in R, but the basic ones you need to know when just starting out for the first time are: Numbers. These come in two varieties: Doubles – where you are wanting and using decimal points, for example 1.23 and 4.56.Integers- where you don’t, for example 1, 2, 3.Strings.

Let’s go through them one-by-one: Where do things live in R? R for Excel Users. One of the more difficult things about learning a new tool is the investment you make while you’re learning things you already know in your current tool. That can feel like time wasted – it’s not, but it’s a very frustrating experience. One of the ways to speed up this part is to ‘translate’ concepts you know in your current tool into concepts for your new one. In that spirit, here’s a brief introduction to where things live in R compared to Excel. Excel is a very visual medium – you can see and manipulate your objects all the time.

You can do the same in R, it’s just that they are arranged in slightly different ways. Data is the most important part. In R you can too – go to the environment window and click on the spreadsheet-looking icon, it will give you your data in the viewer window if it’s an object that can be reproduced like that (if you don’t have this option, your object may be a list not a data frame). In Excel, results and calculations live in a worksheet in a workbook. UseR! talk on teaching R • Michael Levy. Teach the tidyverse to beginners. A few years ago, I wrote a post Don’t teach built-in plotting to beginners (teach ggplot2). I argued that ggplot2 was not an advanced approach meant for experts, but rather a suitable introduction to data visualization.

Many teachers suggest I’m overestimating their students: “No, see, my students are beginners…”. If I push the point, they might insist I’m not understanding just how much of a beginner these students are, and emphasize they’re looking to keep it simple and teach the basics, and that that students can get to the advanced methods later…. My claim is that this is precisely backwards. ggplot2 is easier to teach beginners, not harder, and makes constructing plots simpler, not more complicated.

I’ve continued making this argument in the years since, and I like to think our side is “winning.” I’d summarize the two “competing” curricula as follows: I’ve come to strongly prefer the “tidyverse first” educational approach. Get students doing powerful things quickly Here’s an example. Don't teach students the hard way first. Imagine you were going to a party in an unfamiliar area, and asked the host for directions to their house. It takes you thirty minutes to get there, on a path that takes you on a long winding road with slow traffic.

As the party ends, the host tells you “You can take the highway on your way back, it’ll take you only ten minutes. I just wanted to show you how much easier the highway is.” Wouldn’t you be annoyed? I was recently talking to a friend who works with R and whose opinions I greatly respect. “I teach them dplyr’s group_by/summarize in the second lesson, but I teach them loops first just to show them how much easier dplyr is.” I talk to people about teaching a lot, and that phrase keeps popping up: “I teach them X just to show them how much easier Y is”. Students don’t share your nostalgia First, why do some people make this choice? For instance, I started programming with Basic and Perl in high school, then Java in college, then got really into Python, then got even more into R. Creating an R course on DataCamp. This post builds upon the first post about DataCamp Teach, where you saw how you can create a brand new DataCamp course from scratch.

Creating a course on Datacamp is very easy, but things can go wrong if you're coding up your own course and your source files can't be understood by the DataCamp parsers. In that case, the build messages on DataCamp Teach will tell you what's wrong so you can fix things. Let's experiment a bit and see what happens. As a first example, let's try to add an unsuported exercise type to the DataCamp course. Go to DataCamp Teach and click on the GitHub icon of the course you want to edit. Next, we want to change the first chapter, so we open the file on GitHub. We want to edit this chapter file so we click on the Edit this file icon. Let's change the exercise type of the first exercise, which used to be a VideoExercise, to UnsupportedExercise.

Looks like the build has failed. Commit the change and check the build attempt on DataCamp Teach. RTutor Package. Introducing learnr. Interactive Tutorials for R. Overview The learnr package makes it easy to turn any R Markdown document into an interactive tutorial. Tutorials consist of content along with interactive components for checking and reinforcing understanding. Tutorials can include any or all of the following: Narrative, figures, illustrations, and equations.Code exercises (R code chunks that users can edit and execute directly).Quiz questions.Videos (supported services include YouTube and Vimeo).Interactive Shiny components.

Tutorials automatically preserve work done within them, so if a user works on a few exercises or questions and returns to the tutorial later they can pick up right where they left off. Examples Here are some simple examples of tutorials created with the learnr package: Hello, Tutorial! To create a tutorial, just use library(learnr) within your Rmd file to activate tutorial mode, then use the exercise = TRUE attribute to turn code chunks into exercises. For example, here’s a very simple tutorial: Getting Started Exercises. R/exams. Brief introduction to the new web page and blog of the R/exams project. Welcome everybody, we are proud to introduce the brand new web page and blog This provides a central access point for the open-source software “exams” implemented in the R system for statistical computing. R/exams is a one-for-all exams generator using (potentially) dynamic exercises written in R/Markdown or R/LaTeX and it can export a variety of formats from learning management systems to classical written exams.

This post gives a brief overview of what has happened so far and what you can expect to find here in the next months. Past The package was originally started more than a decade ago to facilitate classical written exams with randomized exercises for large-lecture courses. Like many other teachers of introductory statistics and mathematics courses, we were in need of infrastructure for conducting written exams with about 1,000-1,500 students. Present Future Thanks. Automating R exercises and exams using the exams package. It's a pain to design statistics exercises each semester, and because students from previous share old exercises with the new incoming students, it's hard to design simple exercises that students haven't already seen the answers to.

On top of that, some students try to cheat during the exam by looking over the shoulder of their neighbors. Homework exercises almost always involve collaboration even if you prohibit it. It turns out that you can automate the generation of fixed-format exercises (with different numerical answers being required each time). You can also randomly select questions from a question bank you create yourself. And you can even create a unique question paper for each student in an exam, to make cheating between neighbors essentially impossible (even if they copy the correct answer to question 2 from a neighbor, they end up answering the wrong question on their own paper).

All this magic is made possible by the exams package in R. 1. 2. 3. A "Pre-Training" R Survey. Components of a successful R workshop - Carson's blog on R, RStudio, plotly, shiny, data visualization, statistics, etc. My next workshop is in March at Plotly HQ in Montréal ❄️. I’m also available for R training and general consulting. I had an absolute blast running a 2-day R workshop in NYC last week at plotcon. It was perhaps even more rewarding and fulfilling than my previous plotcon workshop – I saw more attendees grasping concepts, accomplishing exercises, asking great questions, and most importantly, modifying code examples to analyze their own data. There are a few things I think I improved upon this year which helped contribute to the success, so I thought I would share some ideas that can generalize to other R (or, even more generally, data scienc-y) workshops. Inspire first 😲, mindful explanation later 💁 To spark genuine interest and enthusiasm, it’s important to first demonstrate the power of the tools covered in the workshop.

Encourage curiosity about data 🤔 📊 Understand your audience 🕵️‍♀️ Encourage collaboration 👩‍💻 👨‍💻 Bring your work environment to them 💼 💻 Looking forward 🔮 Create Videos from R Markdown Documents with Ari. The real beauty of R Markdown is that it is becoming the plain text platform from which all kinds of data products can be generated: websites, blogs, books, web applications, slide presentations, and academic publications. Ari is an R package which adds video to this portfolio of data products. The following video was generated by Ari from a single R Markdown document: Ari makes it easy to create technical lecture videos that you want to distribute online by latching into your regular data science workflows. To start using Ari there is a little bit of setup. Now that you’re all set up you can install Ari from CRAN: install.packages("ari") Let’s Make a Video The main idea behind Ari is that you should be able to easily create a lecture video just from an R Markdown slide presentation and some written narration.

Library(ari)"ari_comments.Rmd")) --- title: "Ari Comments" author: "Sean Kross" --- <! Why do this? Updating a video is as easy as changing a few lines of text. Make R a Legitimate Part of Your Organization. By Nathan Stephens In many organizations, R enters through the back door when analysts download the free software and install it on their local workstations Jamie has been an avid R programmer since college. When she takes a new job at a large corporation, she finds that she is the only analyst in the company who knows and uses R.

In addition to the other tools her company gives her, Jamie decides to download R onto her laptop. She installs R without consulting her manager or IT. Whether you are an analyst wanting to do more, a stakeholder wanting a competitive analytic platform, or an IT professional wanting a controlled and secured environment, you should make R a legitimate part of your organization and get the resources needed to support it. All organizations have a process for onboarding software through official channels. The last time I introduced R into an organization, I created a presentation explaining why R should be supported by IT.

The review board is responsible for: How do you convince other people to use R? I just got back from the rOpenSci OzUnconf that was run in Melbourne last week. I’d like to give a big thanks to the organizers (Nick Tierney, Di Cook, Rob Hyndman and others) for putting on a great unconference. These events are always a great opportunity to meet people just getting started in the R community and to get them involved. As is typical for these unconferences, topic ideas were pitched via issues on the OzUnconf GitHub repo. One issue that I filed was titled “How do you pitch R to new users?”. While this issue was not taken up during the unconference (for good reason, I think), Nick was kind enough to initiate a lunch time discussion of the topic (with Daniel Falster kindly taking notes). The topic came up in my mind because I’ve found that I’ve had to change the way that I “sell” R to new users.

As part of the introduction to the topic, I talked about how I used to convince others to use R. Free. Reproducibility and Reporting. How wide/deep should an organisation's R guidance go? Hi Ewen, Here’s my experience from the trenches. I work as a data scientist at a big Canadian bank and have been pushing R for over a year. I started using R as a data analyst, looking for a way out of Excel hell. One of the larger pieces of work our team was doing was an annual process that required a lots of iterations, a lot of (ever-updating) data, regular outputs often in graphical format, and a fast turnaround. If only there were a tool that perfectly aligned to all of those needs. Well, that tool was forever Excel. When I joined the team I pushed hard to use R. My VP was still resistant, so I had a strategy for him. That small success led to people approaching me, asking how they too could use R.

Next I started following some of the tips for internal R packages, following examples from Airbnb, to create an internal package that does things like sets up our proxies and standardizes visual identity. That’s how I did it and I’m by no means done. How to create an R culture. Training an Army of Data Scientists. A Data Science Lab for R · R Views.