-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathW10.R
54 lines (27 loc) · 1.49 KB
/
W10.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
49
50
51
52
53
54
# Week 10: Introduction to ggplot2 for Data Visualization
# This week focuses on creating simple and meaningful visualizations
# with the ggplot2 package. Students will learn about aesthetics,
# geometries, themes, and how to add custom elements to plots.
#
# Exercise 1: Creating Your First ggplot
# Load the iris dataset.
# Create a scatter plot of Sepal.Length vs Sepal.Width.
# Set the color of points to represent the Species variable.
# Exercise 2: Exploring Geometries
# Using ggplot2, create a histogram of Petal.Length.
# Set the bins argument to 20.
# Customize the fill color to "skyblue" and add a title to the plot.
# Exercise 3: Faceting by Species
# Create a scatter plot of Petal.Length vs Petal.Width.
# Facet the plot by Species using facet_wrap().
# Set the point color to Species.
# Exercise 4: Adding Custom Themes
# Recreate the scatter plot from Exercise 1.
# Apply the theme_minimal() theme.
# Add custom axis labels, a plot title, and set the legend title to "Flower Type."
# Exercise 5: Combining Layers
# Create a plot showing both a scatter plot and a linear regression line for Sepal.Length vs Sepal.Width.
# Use geom_point() for points and geom_smooth() with method lm for the line.
# Color points by Species.
# Show & Tell: Try Something New
# Explore a ggplot2 function not covered here or customize your plot further. Share your findings and de34monstrate how you applied it to visualize data differently.