R Programming: Data Manipulation with dplyr (Step-by-Step)
Skills:
Data Literacy80%
Key Takeaways
Learning data manipulation with dplyr in R, including filter, select, and arrange functions
Full Transcript
Welcome. I'm glad you're here and ready to explore some incredibly useful R functions from the dlier package. Filter function, select function, and arrange function. By the end of this screencast, you'll be comfortable using these core functions to handle common data tasks like isolating relevant records from your data set, selecting only the columns required for analysis, and effectively sorting your records. I promise this is simpler than it may initially seem. By the end of our time together, you'll feel confident applying these methods to scenarios you regularly encounter and work. To start, let's quickly confirm you have everything you need. If you don't yet have the deeply package installed, that's perfectly okay. You can install it easily by using install.packages command like this. Type in dlier in the argument. As you can see, it is downloading. Once installed, go ahead and load the package using the library function as you can see above. This will help you proceed. In this demonstration, we'll use the built-in empty cars data set. It's a compact, straightforward data set included in R, ideal for practicing new techniques. Let's take a brief look at how it looks. As you see, we've got columns like MPG or miles per gallon, CL, number of cylinders, and HP horsepower. You may spot a lot of similarity with data from your own work. Perhaps product specifications, employee performance metrics, or even monthly sales figures. Let's start with the filter function. This function allows you to keep only those rows that satisfy certain conditions. For example, if you're interested in vehicles that have an miles per gallon value higher than 20, you'd run the following. Let's define that as high efficiency cars. Assign it the filter function. First we put our data set name empty cars followed by a comma and then the condition miles per gallon greater than 20. Now we print it afterwards. Let's see how it looks. Let's briefly unpack that. The first argument is always the original data set empty cars. And the second argument defines our condition miles per gallon greater than 20. In other words, we're instructing R to return only rows greater than 20 for miles per gallon. This is simpler than it may initially look. And after trying it once or twice yourself, you'll see it's straightforward intuitive. Here is the data set. Now, a quick tip to help prevent common mistakes here. When setting equality conditions in R, always use a double equal sign. In our current example, comparing with greater than, this is not necessary, but it's worth remembering for future cases. Next, let's talk about the select function. The select function simplifies your data by keeping only the columns needed for your analysis. Suppose you're preparing a quick efficiency report or only need miles per gallon, cylinder, and horsepower columns from the original data set. To achieve this, you specify the columns in select function. Let's call this new data set or subset of data car summary. We use a select function followed by data set empty cars then all the columns that we're interested in mpg c and hp. Let's print this. See how the data only selected miles per gallon, cylinder, and horsepower. In practice, select helps cut down clutter, simplifying your reports and making large data sets more manageable. A small but useful condition, additional tip here, to remove unwanted columns instead of having to pick any columns manually, you can use the minus sign in front of column names you want to exclude. For example, select empty cars. Mine has gear. Let's type that out. Select empty cars followed by minus gear minus am. Excellent. Now moving on to the range function. The range function sorts your rows based on a specified column. Suppose you want to organize your data by miles per gallon in ascending order. You type sorted cars, assign it the arrange function, specify our data empty cars, followed by miles per gallon. Now let's print and see how this looks. See how miles per gallon is sorted in an ascending manner. But what if you need to determine cars with the highest miles per gallon at the tops? Perhaps to respond directly to a manager's inquiry about top performer vehicles. Arranging in descending order is just one simple step away and again simpler than it may initially sound. Let's clear our terminal and write our query in a different way. Let's call it sorted cars descending. assign it the arrange function. Select our data set empty cars but adding the descending function to our miles per gallon. Let's print this and see how it looks. See how it's now in descending order with the Toyota Corolla being at the top. Remember the arrange sorts ascending by default, but you only need to wrap your chosen column in descending function to reverse this order. It becomes intuitive quickly with practice. I'm confident you'll master this comfortably. Let's briefly touch on a best practice that's coming among our professionals. Combining multiple commands into a logical pipeline using what's known as a pipe operator. percent sign greater than percent sign. This operator helps you write your data task cleanly, almost as though you're guiding a colleague step by step through the analysis. Let's combine all the steps we practiced earlier in one clear sequence. We'll filter for cars with miles per gallon above 20. Select the columns miles per gallon, cylinder, and horsepower. And then arrange the resulting subset by horsepower highest first. First, let's define our subset empty cars adj for adjusted. We will do our assignment operator. Use our data set empty cars. Use the pipe operator followed by the filter function with miles per gallon over 20. Use another pipe operator followed by the select function with miles per gallon cy lp. Then we will use a final pipe operator to use the arrange function and put our condition of descending horsepower. Let's see how this looks. Notice that we only have our three columns that we selected where miles per gallon is above 20 and it's sorted in descending order by the horsepower column. As you see, writing code this way greatly improves readability for yourself and other colleagues who might review it. It even helps those developing familiarity with R quick quickly grasp your overall intention. A brief caution that can save you from frustration later. Ensure your pipe operator appears at the end of each line except the final operation of your sequence. If you encounter any errors running code like this, that's a first thing to double check, an easy fix. Before wrapping up, another brief practical tip. If your workflow involves typing repetitive commands, using a code assisted tool such as GitHub Copilot may help accelerate your scripting. Remember to always confirm carefully that your final code aligns precisely with your intended analysis. In this screencast, you've been introduced to practical ways of leveraging filter function, select function, and arrange function with confidence and clarity. You're now positioned to apply those valuable tools directly to your task at work, strengthening your data skills step by step. Keep going and practice applying these functions to realistic scenarios to consolidate your understanding. Soon enough, you'll find yourself handling your data tasks clearly and efficiently. You've got this.
Original Description
Learn three powerful dplyr functions for data manipulation in R. This Microsoft tutorial covers filter(), select(), and arrange() with practical examples using the mtcars dataset. Perfect for beginners and intermediate R programmers.
🕐 Timestamps:
0:00 - Introduction
0:45 - Installing dplyr Package
1:26 - Understanding mtcars Dataset
2:07 - Filter Function Basics
3:35 - Select Function Tutorial
4:48 - Arrange Function Demo
6:54 - Combining Commands with Pipes
8:37 - Best Practices & Tips
9:12 - Conclusion
🎓 This is a course preview of the *Microsoft R Programming for Everyone Professional Certificate* on Coursera. With the complete program, you'll:
• Learn to write efficient R code
• Collaborate through GitHub
• Analyze complex datasets
• Use AI tools to enhance productivity
• No prior programming experience needed
• Build a professional portfolio of hands-on projects using real datasets in a Microsoft development environment
Enroll now to access the complete 5-course program 👇
https://bit.ly/4hSuvEM
#RProgramming #DataScience #dplyr
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Coursera · Coursera · 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
Principles of Obesity Economics with Professor Kevin Frick
Coursera
Introduction to the U.S. Food System: Perspectives from Public Health by John Hopkins University
Coursera
E-learning and Digital Cultures
Coursera
Equine Nutrition with Jo-Anne Murray
Coursera
Coursera Meetup BBQ
Coursera
Contraception: Choices, Culture and Consequences with Jerusalem Makonnen
Coursera
Nutrition for Health Promotion and Disease Prevention with Katie Clark
Coursera
Information Security and Risk Management in Context with Dr. Barbara Endicott-Popovsky
Coursera
Contraception: Choices, Culture and Consequences with Jerusalem Makonnen
Coursera
Writing in the Sciences with Kristin Sainani
Coursera
Economic Issues, Food, and You with Jennifer Clark
Coursera
Leading Strategic Innovation and Creativity in Organizations with David A. Owens, PhD
Coursera
Useful Genetics with Professor Rosie Redfield
Coursera
A History of the World since 1300!!!! with Jeremy Adelman
Coursera
Microeconomics with Richard McKenzie
Coursera
Discrete Optimization with Professor Pascal Van Hentenryck
Coursera
Leading Strategic Innovation and Creativity in Organizations with David A. Owens, PhD
Coursera
Science from Superheroes to Global Warming with Michael Dennin
Coursera
Introduction to Digital Sound Design with Steve Everett by Emory University
Coursera
Women and the Civil Rights Movement with Dr. Elsa Barkley Brown
Coursera
Galaxies and Cosmology with S. George Djorgovski
Coursera
Science, Technology, and Society in China I, II, and III: Basic Concepts with Naubahar Sharif
Coursera
Introduction to Pharmacy with Kenneth M. Hale, R.Ph., Ph.D.
Coursera
AIDS with Kimberley Sessions Hagen, EdD
Coursera
Health Informatics in the Cloud with Mark Braunstein
Coursera
Songwriting with Pat Pattison by Berklee College of Music
Coursera
Software Defined Networking with Dr. Nick Feamster
Coursera
Epigenetic Control of Gene Expression with Dr Marnie Blewitt
Coursera
Guitar for Beginners - Introduction to Guitar with Thaddeus Hogarth by Berklee College of Music
Coursera
Organizational Analysis with Daniel McFarland
Coursera
Scientific Computing with J. Nathan Kutz
Coursera
Jazz Improvisation - Introduction to Improvisation with Gary Burton by Berklee College of Music
Coursera
Principles of Economics for Scientists with Antonio Rangel
Coursera
Introduction to Music Production with Loudon Stearns by Berklee College of Music
Coursera
Principles of Public Health with Zuzana Bic
Coursera
The Science of Gastronomy with King Chow, Lam Lung Yeung by HKUST
Coursera
The Language of Hollywood: Storytelling, Sound, and Color with Scott Higgins by Wesleyan University
Coursera
Nutrition and Physical Activity for Health with John M. Jakicic, Ph.D., and Amy D. Rickman,...
Coursera
Nutrition, Health, and Lifestyle: Issues and Insights with Jamie Pope, MS, RD, L
Coursera
Survey of Music Technology with Jason Freeman by Georgia Institute of Technology
Coursera
Exercise Physiology: Understanding the Athlete Within with Mark Hargreaves
Coursera
Canine Theriogenology for Dog Enthusiasts with Margaret V. Root
Coursera
Web Intelligence and Big Data with Gautam Shroff
Coursera
Critical Perspectives on Management with Rolf Strom-Olsen
Coursera
El ABC del emprendimiento esbelto with Sergio Ortiz Valdes
Coursera
Interprofessional Healthcare Informatics with Karen Monsen
Coursera
Creativity, Innovation, and Change with Jack V. Matson, Darrell Velegol and Kath
Coursera
Innovacion educativa con recursos abiertos with Maria Soledad Ramirez Montoya an
Coursera
Inspiring Leadership through Emotional Intelligence with Richard Boyatzis
Coursera
Matematicas y movimiento with
Coursera
Sustainability of Food Systems: A Global Life Cycle Perspective with Jason Hill
Coursera
Latin American Culture with Enrique Tames
Coursera
Latin American Culture' with undefined
Coursera
Computer Security with Dan Boneh
Coursera
Introduction to Art: Concepts & Techniques
Coursera
Programmed cell death
Coursera
El ABC del emprendimiento esbelto
Coursera
Understanding economic policymaking
Coursera
History of Rock, Part 1 by University of Rochester
Coursera
Pensamiento Cientifico
Coursera
More on: Data Literacy
View skill →Related Reads
📰
📰
📰
📰
From Apple Health Data to Clinical Storytelling: Building an AI-Powered Report with Python and Gemini
Dev.to · Romina Elena Mendez Escobar
Gemini Notebook: Vet Articles Before You Save
Medium · AI
Claude HUD: Adding a Terminal Heads-Up Display to Claude Code
Dev.to AI
AI Resume Generator That Gets Shortlisted
Dev.to · Amrendra N Mishra
Chapters (9)
Introduction
0:45
Installing dplyr Package
1:26
Understanding mtcars Dataset
2:07
Filter Function Basics
3:35
Select Function Tutorial
4:48
Arrange Function Demo
6:54
Combining Commands with Pipes
8:37
Best Practices & Tips
9:12
Conclusion
🎓
Tutor Explanation
DeepCamp AI