<jupyter_start><jupyter_text>Short Demo of R in JupyterDemonstrations from http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html.For more details on the code, read through this specific section: [Correlation/Scatterplot](http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.htmlScatterplot).<jupyter_code>options(scipen=999)  # turn-off scientific notation like 1e+48
library(ggplot2)
theme_set(theme_bw())  # pre-set the bw theme.
data(mpg, package="ggplot2") # alternate source: "http://goo.gl/uEeRGu")
g <- ggplot(mpg, aes(cty, hwy))

# Scatterplot
g + geom_point() + 
  geom_smooth(method="lm", se=F) +
  labs(subtitle="mpg: city vs highway mileage", 
       y="hwy", 
       x="cty", 
       title="Scatterplot with overlapping points", 
       caption="Source: midwest")
data("midwest", package = "ggplot2")
# 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)<jupyter_output>`geom_smooth()` using formula 'y ~ x'

Warning message:
“Removed 15 rows containing non-finite values (stat_smooth).”
Warning message:
“Removed 15 rows containing missing values (geom_point).”
{'fraction_non_alphanumeric': 0.14801699716713881, 'fraction_numerical': 0.020538243626062325, 'mean_word_length': 4.652, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '28579', 'license': 'MIT', 'n_tokens_mistral': 558, 'n_tokens_neox': 510, 'n_words': 105, 'path': 'r/01-R-Notebook-Demo.ipynb', 'repo_name': 'DennisH3/jupyter-notebooks', 'size': '1412'}