Contents
This level is for learners who know the basics of R. You will learn to select, filter, and group data, clean messy files, draw charts, and run simple statistical tests.
At the end, you will clean a messy student file and find what affects student marks. Every skill is practised on the same student data, so you can see how the steps connect.
Data Manipulation with R
Selecting and Filtering Data
The dplyr package gives you simple verbs for data work. The select() verb picks columns, and the filter() verb picks rows that meet a rule.
Use the pipe symbol, %>%, to pass the result of one step into the next. It lets you read your code from left to right, like a sentence. Filter early in your steps, so later steps work on fewer rows and run faster.
This example finds students in section A with attendance above 90.

Sorting, Grouping, and Summarizing Data
The arrange() verb sorts rows. The group_by() verb splits data into groups, and summarise() gives one result for each group.

Together, they answer questions such as: What is the average maths mark in each section?
Grouping is one of the most useful skills in data analysis because most business questions compare groups. Always check the group sizes with n(), because averages from very small groups can mislead.
Creating and Modifying Columns
The mutate() verb adds a new column or changes an old one. Here, we create an average mark for each student and sort from highest to lowest.
You can use mutate() to make any calculated column, such as a percentage, a grade, or a category. Keep the original column when you can and add a new one, so you can always compare.

R for Data Science
Harini A








