1. Learn
  2. /
  3. Courses
  4. /
  5. Analyzing Survey Data in R

Exercise

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.

Instructions 1/2

undefined XP
    1
    2
  • Create a bubble plot of Height (as x) and Weight (as y) in NHANESraw. Add a line of best fit using geom_smooth() with method = "lm" and mapping WTMEC4YR to weight.