0
0
R Programmingprogramming~30 mins

Scatter plots (geom_point) in R Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Scatter plots (geom_point)
📖 Scenario: You are a data analyst working with a small dataset of car speeds and stopping distances. You want to visualize the relationship between speed and distance using a scatter plot.
🎯 Goal: Create a scatter plot using geom_point in ggplot2 to show how car speed relates to stopping distance.
📋 What You'll Learn
Create a data frame called cars_data with columns speed and dist using the exact values provided.
Create a variable called plot_title with the exact string 'Speed vs Stopping Distance'.
Use ggplot with geom_point to create a scatter plot of speed on the x-axis and dist on the y-axis.
Add the title stored in plot_title to the plot using ggtitle().
Print the plot object to display the scatter plot.
💡 Why This Matters
🌍 Real World
Scatter plots help visualize relationships between two numeric variables, such as speed and stopping distance in cars.
💼 Career
Data analysts and scientists use scatter plots to explore data patterns and communicate findings clearly.
Progress0 / 4 steps
1
Create the data frame
Create a data frame called cars_data with two columns: speed containing the values 4, 7, 8, 9, 10 and dist containing the values 2, 10, 15, 20, 25.
R Programming
Need a hint?

Use data.frame() with speed = c(...) and dist = c(...) to create the data frame.

2
Add a plot title variable
Create a variable called plot_title and assign it the string 'Speed vs Stopping Distance'.
R Programming
Need a hint?

Assign the exact string to plot_title using the assignment operator <-.

3
Create the scatter plot
Use ggplot with the data frame cars_data. Map speed to the x-axis and dist to the y-axis. Add geom_point() to create the scatter plot points.
R Programming
Need a hint?

Use ggplot(data, aes(x = ..., y = ...)) + geom_point() to create the scatter plot.

4
Add title and display the plot
Add the title stored in plot_title to the plot using ggtitle(plot_title). Then print the plot object to display the scatter plot.
R Programming
Need a hint?

Use plot + ggtitle(plot_title) to add the title, then print(plot) to show the plot.