Question: Use the `msleep` dataset provided by **ggplot2**. See here for details: https://ggplot2.tidyverse.org/reference/msleep.html * Visualized the relationship between the total amount of sleep and body weight

Use the `msleep` dataset provided by **ggplot2**. See here for details: https://ggplot2.tidyverse.org/reference/msleep.html

* Visualized the relationship between the total amount of sleep and body weight in each mammal classified as a carnivore (`vore == "carni"`), using a log scale for body weight. Your plot should include raw data points and a linear trendline with a confidence interval. What do you observe?

* use the function to create the plot above. The function should have two inputs: `data`, which is the dataset to plot, and `vore`, which is a string indicating the vore type, such as `"carni".` Reproduce the plot using the new function.

* Write code that automatically applies the function created to all vore types ( exclude `NA` values). **Do not write a `for` loop.** How does the relationship between body weight and total sleep duration vary across vores?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!