These exercises cover the sections of Plotting in R PlottingInR.
Please load the dateset mtcars by calling data(mtcars) and use the base R graphics to
create a scatter plot of mtcars$mpg
VS mtcars$wt
(x-axis = mpg and y-axis = wt).
change the axis labels to x axis = “Miles/(US) gallon” and y axis = “Weight (1000 lbs)”
add title = “scatter plot”
change the colour of data points to red and the the shape of points to “filled circle”
[hint: use data()
function to load mtcars]
data(mtcars)
head(mtcars)
Please load the dateset mtcars by calling data(mtcars) and use ggplot2 to
create a scatter plot of mtcars$mpg
VS mtcars$wt
(x-axis = mpg` and y-axis = wt).
change the axis labels to x axis = “Miles/(US) gallon” and y axis = “Weight (1000 lbs)”
add title = “scatter plot”
change the colour of data points to red [hint: use col="red"
when constructing aesthetic mappings]
what will happen if change the colour of points to mtcars$am
[hint: use col=am
when constructing aesthetic mappings]
what will happen if change the colour of points use col=as.factor(am)
when constructing aesthetic mappings