Skip to content
R for the Rest of Us: A Statistics-Free Introduction comes out June 25th. Or you can read the online version today. Check it out →
R for the Rest of Us Logo

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

Complete the scatterplot sections of the data-visualization-exercises.Rmd file.

Learn More

Scatterplot Resources

Claus Wilke talks about scatterplots in Chapter 12 of his book Fundamentals of Data Visualization. Michael Toth also has a long blog post about all of the ins and outs of making scatterplots in ggplot.

You can also find examples of code to make scatterplots on the Data to Viz website , the R Graph Gallery website , and in Chapter 5 of the R Graphics Cookbook.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Jeff Shandling

Jeff Shandling

April 5, 2021

Getting the following error: Error in loadNamespace(name) : there is no package called ‘farver’ when I add the mapping code, the variables are not auto-populating

Abby Isaacson

Abby Isaacson

April 6, 2021

We may not be there yet, but for axis labeling if we wanted to add units to the labels, is that easy?

Jimmy Frickey

Jimmy Frickey

April 26, 2021

Hi David,

Here are 2 versions of code that both produce the scatterplot of height vs weight from nhanes dataset. The first is from your solutions, and the second if following r4ds text. Can you briefly comment on why they both "work"? Is one better than another?

ggplot(data = nhanes, mapping = aes(x = weight, y = height)) + geom_point()

ggplot(data = nhanes) + geom_point(mapping = aes(x = weight, y = height))

Juan Clavijo

Juan Clavijo

October 11, 2021

You mentioned that ggplot will automatically remove observations with missing data. If I'm plotting average test scores for mid-term and final exams, for example, and one student took the final but did not take the mid-term, will ggplot remove that student's data from the graph completely, or will it just plot the final exam and omit the mid-term score that does not exist?

Esther Okoye

Esther Okoye

April 5, 2022

Hello, Please i cant the data visualization exercise on my studio, do i have to do anything?

Elijah Phillips

Elijah Phillips

October 13, 2022

Where do we get the .rmd file for this?

Ellen Wilson

Ellen Wilson

November 1, 2022

It seems like the clean_names function didn't work for me--when I start typing the code for the scatterplot, it isn't suggesting the variable names. This is what I put for clean_names

nhanes %
  clean_names()

And then I got this message (which looks different from what you got)

Rows: 10000 Columns: 22── Column specification ────────────────────────────────────────────────────────────────────────────── Delimiter: "," chr (13): SurveyYr, Gender, AgeDecade, Race1, Education, MaritalStatus, HHIncome, HomeOwn, Work, H... dbl (9): ID, Age, Weight, Height, BMI, DaysPhysHlthBad, DaysMentHlthBad, SleepHrsNight, PhysActiv... ℹ Use spec() to retrieve the full column specification for this data. ℹ Specify the column types or set show_col_types = FALSE to quiet this message.

Oscar Tetteh

Oscar Tetteh

March 28, 2023

Please could you email me the nhames data set? This is my mail: bismarktetteh25@gmail.com