Code Studio: Two Plotting Systems
Base-R and ggplot2 Graphics introduces R's two plotting systems. Draw the same picture in both.
The program reads the name of a column of mtcars, such as mpg.
- With base R, draw a scatterplot of that column against
wtusingplot(), with axis labels. - With ggplot2, draw the same scatterplot using
geom_point(), andprint()it. - Print the correlation between
wtand the column, rounded to 3 decimal places, asCorrelation: …
For mpg the output is Correlation: -0.868.
Compare the two pictures. What does ggplot2 give you without asking, and what took more typing?
Run draws your plot under the output. Check and Submit test the numbers your program prints.
Base-R and ggplot2 Graphics introduces R's two plotting systems. Draw the same picture in both.
The program reads the name of a column of mtcars, such as mpg.
- With base R, draw a scatterplot of that column against
wtusingplot(), with axis labels. - With ggplot2, draw the same scatterplot using
geom_point(), andprint()it. - Print the correlation between
wtand the column, rounded to 3 decimal places, asCorrelation: …
For mpg the output is Correlation: -0.868.
Compare the two pictures. What does ggplot2 give you without asking, and what took more typing?
Run draws your plot under the output. Check and Submit test the numbers your program prints.