in R Language by
Scatterplot in  R language

▼ Show 1 Answer

0 votes

Let's see how ggplot works with the mtcars dataset. You start by plotting a scatterplot of the mpg variable and drat variable.

Basic scatter plot

ggplot(mtcars, aes(x = drat, y = mpg)) +

Code Explanation

  • You first pass the dataset mtcars to ggplot.
  • Inside the aes() argument, you add the x-axis and y-axis.
  • The + sign means you want R to keep reading the code. It makes the code more readable by breaking it.
  • Use geom_point() for the geometric object.
Learn More with Madanswer

Related questions

0 votes
asked Nov 14, 2019 in R Language by MBarbieri