The column "z" in the diamonds dataset represents a diamond's depth in millimeters. Create a scatter plot of the diamonds dataset with z on the x axis and price on the y axis.
ggplot(diamonds, aes(x=z, y=price)) + geom_point()
Create a scatter plot of the diamonds dataset with z on the x axis, price on the y axis, and coloring points based on their cut.
ggplot(diamonds, aes(x=z, y=price, color=cut)) + geom_point()
Create a scatter plot of the diamonds dataset with z on the x axis, price on the y axis, and coloring points based on their cut, but this time add smoothing curves to show the trend.
ggplot(diamonds, aes(x=z, y=price, color=cut)) + geom_point() + geom_smooth()
The Orange data.frame is a dataset that comes built into R, which describes the height of five orange trees over time. It has three columns "Tree" (a factor describing which of five trees is being measured), "age" (the age in days at the point of measurement), and "circumference" (the circumference of the tree trunk in millimeters).
Load the Orange dataset into memory.
data("Orange")
View the Orange dataset like a spreadsheet.
View(Orange)
Create a scatter plot of the Orange dataset with age on the x-axis and circumference on the y-axis
ggplot(Orange, aes(x=age, y=circumference)) + geom_point()
Create a scatter plot of the Orange dataset with age on the x-axis and circumference on the y-axis, with each point colored according to which tree it represents
ggplot(Orange, aes(x=age, y=circumference, color=Tree)) + geom_point()
Create a scatter plot of the Orange dataset with age on the x-axis and circumference on the y-axis, with each point colored according to which tree it represents, and a best fit straight line (not curve!) for each
ggplot(Orange, aes(x=age, y=circumference, color=Tree)) + geom_point() + geom_smooth(method="lm")