Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. I need to get RStudio code following by these instructions. Use the R Markdown file `midterm.Rmd` for answering the questions below. Remember to fill

1. I need to get RStudio code following by these instructions.

Use the R Markdown file `midterm.Rmd` for answering the questions below. Remember to fill in your name at the top of the R Markdown document and be sure to save, commit, and push (upload) frequently to Github so that you have incremental snapshots of your work. When youre done, follow the [How to submit](#how-to-submit) section below to submit your Midterm Exam for grading.

## The mammals sleep dataset

For the Midterm Exam, you will be creating visualizations of the `msleep` dataset, which is loaded automatically with the `tidyverse` package. This is an updated and expanded version of the mammals sleep dataset. Updated sleep times and weights were taken from V. M. Savage and G. B. West. A quantitative, theoretical framework for understanding mammalian sleep. Proceedings of the National Academy of Sciences, 104 (3):1051-1056, 2007. The dataset contains 83 observations over 11 variables.

| Variable | Description | | :------- | :---------- | | `name` | common name | | `genus` | Taxonomic rank used for classifying organisms | | `vore` | carnivore, omnivore, insectivore, or herbivore? | | `order` | Taxonomic rank used for classifying organisms | | `conservation` | the conservation status of the animal | | `sleep_total` | total amount of sleep, in hours | | `sleep_rem` | REM sleep, in hours | | `sleep_cycle` | length of sleep cycle, in hours | | `awake` | amount of time spent awake, in hours | | `brainwt` | brain weight in kilograms | | `bodywt` | body weight in kilograms | ## Questions

1. Create a density plot that allows you to answer the following question: on average, do carnivores, herbivores, insectivores, or omnivores have the longest stage of REM sleep? Then, answer the question, ignoring any `NA` values in the `vore` column.

Hint You will need to include two separate inputs inside the `aes()` function, and also use `alpha = 0.5` somewhere so that you can see the distributions.
2. Create a bar chart that counts how many carnivores, herbivores, insectivores, and omnivores are in this dataset. Ignoring the `NA` values, which category shows up the most in the dataset? Which category shows up the least? 3. Create a scatter plot of the relationship between the length of time an animal spends in REM sleep and the amount of time it spends awake. The time spent in REM sleep should be displayed on the vertical axis and the length of time awake should be displayed on the horizontal axis. 4. `filter` the dataset so that it only contains observations of animals with a body weight less than 250 kilograms. Assign the result into a variable called `msleep_filtered`. Then, create a scatter plot using `msleep_filtered` showing the trend between an animal's body weight and the number of hours it spends awake. The body weight should be on the vertical axis and the number of hours spent awake should be on the horizontal axis. **After you create the visualization, provide an answer to the following question:** Would you conclude from your plot that there is there a clear and strong correlation between body weight and the number of hours an animal is awake?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

4. Name and describe the main internal sources of candidates.

Answered: 1 week ago