-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathW5.R
48 lines (23 loc) · 1.25 KB
/
W5.R
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
# Week 5: Data Transformation with dplyr Assignment
# This week focuses on introducing students to dplyr functions,
# a cornerstone of tidy data transformation in R.
# You will learn key verbs like filter(), select(), mutate(), arrange(), and summarize().
# Exercise 1: Filtering Rows
# Load the mtcars dataset using data(mtcars).
# Filter rows where mpg > 25 and cyl == 4.
# Save this filtered data to an object called high_mpg_cars.
# Exercise 2: Selecting Columns
# Select only the columns mpg, cyl, wt, and gear.
# Save the result as selected_cars.
# Exercise 3: Creating New Columns
# Create a new column power_to_weight by dividing hp by wt.
# Create another column efficient that is TRUE if mpg > 20, otherwise FALSE.
# Exercise 4: Arranging Rows
# Arrange the dataset by mpg in descending order.
# Break ties by wt in ascending order.
# Exercise 5: Summarizing Data
# Group the data by cyl and calculate the mean mpg and mean hp.
# Use summarise() to display these grouped summaries.
# Show & Tell Bonus: Try Something New
# Experiment with another dplyr function (like case_when() or across()) and share your code.
# What new skill did you learn? How could it be applied to your data own projects?