LoslegenKostenlos loslegen

Line of best fit

What's the relationship between height and weight across all ages?

In this exercise, we will add the line of best fit to a bubble plot and see that the trend isn't very linear. We can create a polynomial curve by adding the argument formula = y ~ poly(x, d) to geom_smooth() where d is the degree of the polynomial. For example, d of 2 adds a quadratic and a d of 3 adds a cubic.

Diese Übung ist Teil des Kurses

Analyzing Survey Data in R

Kurs anzeigen

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Bubble plot with linear of best fit
ggplot(data = NHANESraw, mapping = aes(x = ___, y = ___, size = ___)) + 
  geom_point(alpha = 0.1) + 
  guides(size = "none") + 
  geom____(method = ___, se = FALSE, mapping = aes(___))
Code bearbeiten und ausführen