Top 25 shapes of ggplot 5 - 4 - 3 - 2 - 1 - 1 2 3 x 4 5 0 1 2 3 4 5 6 7 8 9 10 11 12 z 13 14 15 16 17 18 19 20 21 22 23 24
Added by Jonathan S.
Close
Step 1
Step 1: Load the necessary libraries ```R library(ggplot2) library(dplyr) ``` Show more…
Show all steps
Your feedback will help us improve your experience
Rashmi Prakash and 59 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
# Install the package if you have not installed it before ("ggplot2") # Load the package library (ggplot2) Load the mpg dataset data ("diamonds") Problem 1 (1 x 5 = 5 points) Use ggplot2 to visualize the data. You need to paste the resulting plots and related code in order to get the full points. For each ggplot plot: • make it complete/readable, in other words, it should include axis label(s), title, and legend if necessary; • write 1-2 sentences about what the chart tells you about the data. (a) Choose bin number or binwidth (Hint: See page 11 of lecture_04c.pdf), explain why; and create a histogram of carat. (b) Make a scatter plot of y = price against x = carat and set the color to clarity. (c) Make a scatter plot of y = price against x = carat and add a smooth line to each group of points defined by clarity. (d) Make a scatter plot of y = price against x = carat and facet it by clarity. (e) Show carat VS cut, make a point, jitter, box plot, and a violin plot, respectively. Which one is the best for visualization?
Sri K.
The following R code below will add variable BMI (Body Mass Index) and produce the graph on a scatter plot of the heightweight (hw) data. hw$BMI <- hw$weightLb / (hw$heightIn)^2 * 703 ggplot(hw, aes(x = heightIn, y = weightLb, colour = sex)) + geom_point() The output of the plot is given in the left panel. Figure 1: Left panel is for the given R code and right panel is for the requested R code. Modify the above code so that you get the graph (a) on the right panel in the graph above. (b) on the left panel in the graph below. (c) on the right panel in the graph below. Figure 2: Left panel is for Part (b) and right panel is for Part (c).
Adi S.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD