My first figure of the Gapminder data
p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap,
y = lifeExp))
p + geom_point()

p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap,
y = lifeExp))
p + geom_smooth()
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap,
y = lifeExp))
p + geom_point() + geom_smooth()
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap, y = lifeExp))
p + geom_point() +
geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'

scale_x_log10()
## <ScaleContinuousPosition>
## Range:
## Limits: 0 -- 1
p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap, y = lifeExp))
p + geom_point() +
geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'

scale_x_log10(labels = scales::dollar)
## <ScaleContinuousPosition>
## Range:
## Limits: 0 -- 1
p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap, y = lifeExp,
color = "purple"))
p + geom_point() +
geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

scale_x_log10(labels = scales::dollar)
## <ScaleContinuousPosition>
## Range:
## Limits: 0 -- 1
p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap, y = lifeExp,))
p + geom_point(color = "purple") +
geom_smooth(method = "loess")
## `geom_smooth()` using formula = 'y ~ x'

scale_x_log10(labels = scales::dollar)
## <ScaleContinuousPosition>
## Range:
## Limits: 0 -- 1
p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap, y = lifeExp,))
p + geom_point(alpha = 0.3) +
geom_smooth(color = "orange",
se = FALSE,
size = 8,
method = "lm")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## `geom_smooth()` using formula = 'y ~ x'

scale_x_log10(labels = scales::dollar)
## <ScaleContinuousPosition>
## Range:
## Limits: 0 -- 1
p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap, y = lifeExp,))
p + geom_point(alpha = 0.3) +
geom_smooth(method = "lm") +
scale_x_log10(labels = scales::dollar) +
labs(x = "GDP per Capita",
y = "Life Expectancy in Years",
title = "Economic Growth and Life Expectancy",
caption = "Source: Gapminder.")
## `geom_smooth()` using formula = 'y ~ x'

p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap, y = lifeExp,
color = continent,
fill = continent))
p + geom_point(alpha = 0.3) +
geom_smooth(method = "loess") +
scale_x_log10(labels = scales::dollar) +
labs(x = "GDP per Capita",
y = "Life Expectancy in Years",
title = "Economic Growth and Life Expectancy",
caption = "Source: Gapminder.")
## `geom_smooth()` using formula = 'y ~ x'

p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap, y = lifeExp,
color = continent,
fill = continent))
p + geom_point(mapping = aes(color = continent,
fill = continent)) +
geom_smooth(method = "loess") +
scale_x_log10(labels = scales::dollar) +
labs(x = "GDP per Capita",
y = "Life Expectancy in Years",
title = "Economic Growth and Life Expectancy",
caption = "Source: Gapminder.")
## `geom_smooth()` using formula = 'y ~ x'

p <- ggplot(data = gapminder,
mapping = aes(x = gdpPercap, y = lifeExp,
))
p + geom_point(mapping = aes(color = log(pop)))+
geom_smooth(method = "loess") +
scale_x_log10(labels = scales::dollar) +
labs(x = "GDP per Capita",
y = "Life Expectancy in Years",
title = "Economic Growth and Life Expectancy",
caption = "Source: Gapminder.")
## `geom_smooth()` using formula = 'y ~ x'

