This is an R HTML document. When you click the chunk like this:

Scatterplot used plot for data analysis whenever you want to understand the nature of relationship between two variables.
  library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
  library(ggplot2)

  options(scipen=999)               # turn-off scientific notation like 1e+48

  theme_set(theme_bw())             # pre-set the bw theme.
  data("midwest", package = "ggplot2")

              # midwest <- read.csv("http://goo.gl/G1K41K")  # bkup data source
              # Scatterplot
  gg <- ggplot(midwest, aes(x=area, y=poptotal)) +
    geom_point(aes(col=state, size=popdensity)) +
    geom_smooth(method="loess", se=F) +
    xlim(c(0, 0.1)) +
    ylim(c(0, 500000)) +
    labs(subtitle="Area Vs Population",
         y="Population",
         x="Area",
         title="Scatterplot",
         caption = "Source: midwest")
  plot(gg)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 15 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 15 rows containing missing values or values outside the scale range
## (`geom_point()`).
plot of chunk unnamed-chunk-1
Jitter Plot for a new data to draw the scatterplot. This time, use the mpg dataset to plot city mileage (cty) vs highway mileage (hwy).
  library(tidyverse)
  library(ggplot2)

  data(mpg, package="ggplot2")            # alternate source: "http://goo.gl/uEeRGu")
  theme_set(theme_bw())                   # pre-set the bw theme.

  g <- ggplot(mpg, aes(cty, hwy))
                                          # Scatterplot
  g + geom_point() +
    geom_smooth(method="lm", se=F) +
    labs(x="cty", y="hwy",
         title="Scatterplot with overlapping points",
         subtitle="mpg: city vs highway mileage",
         caption="Source: midwest")
## `geom_smooth()` using formula = 'y ~ x'
plot of chunk unnamed-chunk-2