September 2018
Beginner
206 pages
4h 27m
English
Two continuous variables are a good candidate for a scatterplot, which is created using geom_point() in ggplot2. You can also create scatterplots using geom_ jitter(). Using jitter instead of point adds a small amount of noise (tiny on the order of decimals) to each observation, spreading them out from one another slightly so they're easier to see.
We can create a scatterplot with the wt and mpg variables from mtcars using the following code:
ggplot(mtcars, aes(wt, mpg)) + geom_point()

The plot shows a clear relationship between the weight and miles per gallon of the cars, namely as wt increases, the mpg decreases (we saw this ...
Read now
Unlock full access