ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Analyzing Survey Data in R

Ver curso

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# 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(___))
Editar y ejecutar código