Question: Exercise 3: using vectors and objects. In this exercise, we will study two datasets that are shipped with the ggplot2 package: diamonds - describing the
Exercise 3: using vectors and objects.
In this exercise, we will study two datasets that are shipped with the ggplot2 package: diamonds - describing the prices of more than 50,000 cut diamonds and msleep - describing the sleep times of 83 mammals. To install the package from CRAN, you can either select Tools > Install packages in the RStudio menu and then write ggplot2 in the text box in the pop-up window that appears, or use the following line of code: install.packages("ggplot2")
Provide in the plain text R commands that finds/solves the problems below:
- View the documentation for the diamonds data and read about different variables. Check the data structures and answer:
- how many observations and variables are there and what type of variables (numeric, categorical, etc.) are there?
- Compute summary statistics (means, median, min, max, counts for categorical variables).
- Are there any missing values?
Create a scatterplot with total sleeping time along the x-axis and time awake along the y-axis (using the msleep data).
- What pattern do you see?
- Explain the pattern(s).
- Explain the correlation between total sleeping time and time awake.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
