Two examples of iteration with purrr - Class for the RStudio certification
By Florencia D'Andrea in Teaching
June 21, 2020
RStudio Certification
I recently became certified as a RStudio Tidyverse Instructor. To pass the certification there are two exams. In this post, I am going to share a 15 minute class that I prepared to as part of the teaching exam.
What to teach about?
I use loops frequently for my postdoc as I need to automate tasks. That is why I decided to teach two specific examples of iteration using functions in purrr
package.
I find that these examples are motivating for students as these functions offer a simple way to get a lot of work done:
-
Read a group of files with the same extension and get a dataframe using
map_df()
-
Generate Rmarkdown reports from a list of parameters automatically with
pwalk()
Who is the class for?
This class is part of three weeks long data analysis course for graduate students without any previous training in programming.
The 15 minutes are part of the last class of the course. The students already have learned basic topics as visualization, data manipulation, RMarkdown, and iteration.
Some considerations
-
To answer the the exercises in “Let’s Practice” you need concepts that were explained in previous classes. Specially these 15 minutes should be teach after iteration and
Rmarkdown
. -
It is not necessary to use Xaringan for the certification slides.
-
It is important that you practice your class keeping track of how long it lasts.
Files
Slides
Live coding
The file with the code for the live coding is in Live coding.R (wait a bit until R-Studio loads)
ðŸ±ðŸ§¶