R Tutorial : Intermediate Functional Programming with purrr
Key Takeaways
This video tutorial covers intermediate functional programming with purrr, a popular R package, focusing on the map function and its variants, including map_dbl and map2, to iterate over lists and perform computations.
Full Transcript
hello and welcome to this course on programming whisper I'm kunafa I'm a data scientist in our ARCA as you can only Amy there is a picture of me drinking coffee a big part of my day job is writing our code and I use / to help me optimize my workflow notably I use / for writing functions which is what you'll do in this course before starting this course make sure you've got some basic knowledge of iteration using / if you're not familiar with it there are some great resources that can help you learn about iteration with / if you're already familiar iterating with / you can start with schools right now almost every iteration process has two sides the first other elements we iterate over a second is we function we apply to each element / follows with format the first per function everyone learns is the map function map as two elements first dot X which is the object we are iterating over its object can either be a vector a list or a data frame a second part includes that F and V dot argument which represents the functional part of the iteration it's a description of what happens to each element of the object in this course you'll learn how to deal with the second half of a basic / skeleton the dot F and V dot arguments for this course I have extracted three lists from a dataset taken from the open data portal of a French city of Samara this dataset gathers account of a number of visits on the website some are up my fare each shop is newly created lists is a year 2014 2015 and 2016 it contains 12 sub lists corresponding to month each month is a vector with a number of website visits per day these list objects are an extraction of a full data set this list format is one you regularly encounter when carrying data on the web notably when you have to do with a JSON format which is passed as a nested list in our let's start with a refresher of per basic functions using these three lists first let's see the map function the map function runs without f function on each element of dot X and always return the list here we are mapping with some function on the list visit underscore 2015 when strength of Perl is with this types table this means that you always know up front the class of the output here for example we are using map and discord dbl map underscore GPL does the same operation as map but the output is different as you can see the result is a numeric vector rather than a list let's now imagine we want to add visits from 2015 and 2016 to do this I can use the map to function to get a list and its counterpart map to underscore TBL to get a vector of numeric what if we want to do the same computation as we won from the previous slide but with free lists in per there is no map free map for etc if you want to map over move on to elements you need to pass a list of elements to the P map function to iterate over elements in three or more lists you'll need to put all these lists in a novelist and pathways master list as the first argument of P map now it's your turn to refresh your memory
Original Description
Want to learn more? Take the full course at https://learn.datacamp.com/courses/intermediate-functional-programming-with-purrr at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
Hello and welcome to this course on programming with purrr.
I'm Colin Fay; I'm a data scientist and R hacker. As you can only hear me, here is a picture of me drinking coffee.
A big part of my day job is writing R code, and I use purrr to help me optimize my workflow.
Notably, I use purrr for writing functions, which is what you'll do in this course.
Before starting this course, make sure you've got some basic knowledge of iteration using purrr.
If you're not familiar with it, here are some great resources that can help you learn about iteration with purrr.
If you're already familiar iterating with purrr, you can start this course right now!
Almost every iteration process has two sides. The first are the elements we iterate over. The second is the function we apply to each element. purrr follows this format.
The first purrr function everyone learns is the map() function. map() has two elements. First, .x, which is the object we are iterating over — this object can either be a vector, a list, or a data frame.
The second part includes .f and the dot dot dot argument, which represents the functional part of the iteration. It's the description of what happens to each element of the object.
In this course, you'll learn how to deal with the second half of the basic purrr skeleton: the .f and dot dot dot arguments.
For this course, I have extracted three lists from a dataset taken from the open data portal of the French city of St. Malo.
This dataset gathers a count of the number of visits on the website saint-malo.fr.
Each of these newly created lists is a year: 2014, 2015, and 2016. Each contains 12 sublists corresponding to months. Each month is a vector with the number of website visits per day.
These list objects are an
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from DataCamp · DataCamp · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SQL Server Tutorial: Date manipulation
DataCamp
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
R Tutorial: Adding aesthetics to represent a variable
DataCamp
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
Python Tutorial: Preparation for modeling
DataCamp
Python Tutorial: Machine Learning modeling steps
DataCamp
R Tutorial: The prior model
DataCamp
R Tutorial: Data & the likelihood
DataCamp
R Tutorial: The posterior model
DataCamp
R Tutorial: An Introduction to plotly
DataCamp
R Tutorial: Plotting a single variable
DataCamp
R Tutorial: Bivariate graphics
DataCamp
Python Tutorial: Customer Segmentation in Python
DataCamp
Python Tutorial: Time cohorts
DataCamp
Python Tutorial: Calculate cohort metrics
DataCamp
Python Tutorial: Cohort analysis visualization
DataCamp
R Tutorial: Building Dashboards with flexdashboard
DataCamp
R Tutorial: Anatomy of a flexdashboard
DataCamp
R Tutorial: Layout basics
DataCamp
R Tutorial: Advanced layouts
DataCamp
Python Tutorial: Time Series Analysis in Python
DataCamp
Python Tutorial: Correlation of Two Time Series
DataCamp
Python Tutorial: Simple Linear Regressions
DataCamp
Python Tutorial: Autocorrelation
DataCamp
R Tutorial: The gapminder dataset
DataCamp
R Tutorial: The filter verb
DataCamp
R Tutorial: The arrange verb
DataCamp
R Tutorial: The mutate verb
DataCamp
R Tutorial: What is cluster analysis?
DataCamp
R Tutorial: Distance between two observations
DataCamp
R Tutorial: The importance of scale
DataCamp
R Tutorial: Measuring distance for categorical data
DataCamp
Python Tutorial: Plotting multiple graphs
DataCamp
Python Tutorial: Customizing axes
DataCamp
Python Tutorial: Legends, annotations, & styles
DataCamp
Python Tutorial: Introduction to iterators
DataCamp
Python Tutorial: Playing with iterators
DataCamp
Python Tutorial: Using iterators to load large files into memory
DataCamp
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
SQL Tutorial: Tables: At the core of every database
DataCamp
SQL Tutorial: Update your database as the structure changes
DataCamp
Python Tutorial: Classification-Tree Learning
DataCamp
Python Tutorial: Decision-Tree for Classification
DataCamp
Python Tutorial: Decision-Tree for Regression
DataCamp
Python Tutorial: Census Subject Tables
DataCamp
Python Tutorial: Census Geography
DataCamp
Python Tutorial: Using the Census API
DataCamp
R Tutorial: A/B Testing in R
DataCamp
R Tutorial: Baseline Conversion Rates
DataCamp
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
R Tutorial: Introduction to qualitative data
DataCamp
R Tutorial: Understanding your qualitative variables
DataCamp
R Tutorial: Making Better Plots
DataCamp
SQL Tutorial: OLTP and OLAP
DataCamp
SQL Tutorial: Storing data
DataCamp
SQL Tutorial: Database design
DataCamp
Python Tutorial: Introduction to spaCy
DataCamp
Python Tutorial: Statistical Models
DataCamp
Python Tutorial: Rule-based Matching
DataCamp
Related AI Lessons
⚡
⚡
⚡
⚡
This ChatGPT Prompt Replaced 3 Hours of PowerPoint Work
Medium · AI
This ChatGPT Prompt Replaced 3 Hours of PowerPoint Work
Medium · ChatGPT
How AI Assist Turns a Rough Draft into a Polished Document in Minutes
Dev.to · paperquire
13 ways to make money with AI in 2026, ranked by how fast you will see your first dollar.
Medium · AI
🎓
Tutor Explanation
DeepCamp AI