p1 <- mice_weights |>ggplot(aes(x = bone_density, y = body_weight, color = sex))+geom_point()+geom_smooth(method = lm, se=FALSE, color ="purple")+labs(x ="Bone Density", y ="Body Weight", title ="Mice body weight vs bone density by sex", color ="Sex")+theme_minimal()+geom_smooth(method = lm, se=FALSE)p1
`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 4 rows containing non-finite outside the scale range
(`stat_smooth()`).
`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 4 rows containing non-finite outside the scale range
(`stat_smooth()`).
Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
I made a basic Scatter Plot comparing Bone Density to Body weight for mice, and I split them by gender, adding a line of best fit for each gender plus the graph as a whole. It seemed unreasonable to add interactivity with the quanitity of data so I kept it fairly simple. I used geom smooth twice once before the labs so it would give me a line for the graph as a whole, and then once after the labs so it would give me an individual line for each sex.