Skip to content

Latest commit

 

History

History
30 lines (30 loc) · 620 Bytes

File metadata and controls

30 lines (30 loc) · 620 Bytes

Scatterplot

Base R Graphic

Actual Code
One Variable
plot(mtcars$mpg, main = "Scatterplot for `mtcars$mpg`")
Two Variables
plot(mtcars$wt, mtcars$mpg,
     main = "Scatterplot for `mtcars$mpg` on `mtcars$wt`")

ggplot2 Graphic

Preparation Code
# Functions
library(ggplot2)
Actual Code
One Variable
qplot(seq_along(mtcars$mpg), mtcars$mpg) +
  labs(title = "Scatterplot for `mtcars$mpg`")
Two Variables
ggplot(mtcars, aes(y = mpg, x = wt)) +
  geom_point() +
  labs(title = "Scatterplot for `mtcars$mpg` on `mtcars$wt`")