library(rmarkdown)
library(gapminder)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
Create gapminder_1952
gapminder_1952<-gapminder%>%
filter(year==1952)
ggplot(gapminder_1952,aes(x=pop,y=gdpPercap))+
geom_point()
create a scatter plot with pop on the x-axis and lifeExp on the y-axis
ggplot(gapminder_1952,aes(x=pop,y=lifeExp))+
geom_point()
change this plot to put the x-axis on a log scale
ggplot(gapminder_1952,aes(x=pop,y=lifeExp))+
geom_point()+
scale_x_log10()
ggplot(gapminder_1952,aes(x=pop,y=gdpPercap))+
geom_point()+
scale_x_log10()+
scale_y_log10()
scatter plot comparing pop and lifeExp,with color representing continent
ggplot(gapminder_1952,aes(x=pop,y=lifeExp,color=continent))+
geom_point()+
scale_x_log10()
add the size aesthetic to represent a country’s gdpPercap
ggplot(gapminder_1952,aes(x=pop,y=lifeExp,color=continent,size=gdpPercap))+
geom_point()+
scale_x_log10()
scatter plot comparing pop anf lifeExp,faceted by continent
ggplot(gapminder_1952,aes(x=pop,y=lifeExp))+
geom_point()+
scale_x_log10()+
facet_wrap(~continent)
scatter plot comparing gdpPercap and lifeExp,with color representing continent and size representing population,faceted by year
ggplot(gapminder,aes(x=gdpPercap,y=lifeExp,color=continent,size=pop))+
geom_point()+
scale_x_log10()+
facet_wrap(~year)