In this article, you’ll see the basic code of plottings in R. This article is written to give you idea how graphics in R works.
- First, make sure you’ve installed R and RStudio.
- Then, search and open RStudio.
- After that, go to File > New File > R Scripts.
- Copy the code below and run it.
Plotting with R base graphics
title("Regression: MPG vs Weight")
Plotting with ggplot2
To make plots with ggplot2, make sure you have installed the package.
ggplot(mtcars, aes(mpg, wt)) +
ggtitle("Regression: MPG vs Weight")