Categories

Nov 14, 2019 in R Language

Q: Scatterplot in  R language

1 Answer

Nov 14, 2019

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

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

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.
Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

Madanswer
Nov 14, 2019 in R Language
Nov 14, 2019 in R Language
Nov 14, 2019 in R Language
...