Skip to content

Introduction to the Tidyverse

Run the hidden code cell below to import the data used in this course.


1 hidden cell

Take Notes

Add notes about the concepts you've learned and code cells with code you want to keep.

Add your notes here

# Add your code snippets here

library(gapminder)
library(dplyr)
library(ggplot2)

ggplot(gapminder_1952, aes(x = pop, y = gdpPercap)) +
  geom_point()

ggplot(gapminder_1952, aes(x = pop, y = lifeExp)) +
  geom_point()

ggplot(gapminder, aes(x = gdpPercap, y = lifeExp, color = continent, size = pop)) +
    geom_point() +
    scale_x_log10() +
    facet_wrap(~ year)

gapminder %>%
    group_by(continent, year) %>%
    summarize(medianLifeExp = median(lifeExp),
    maxGdpPercap = max(gdpPercap))



by_continent_2007 <- gapminder %>%
    filter(year == 2007) %>%
    group_by(continent) %>%
    summarize(medianLifeExp = median(lifeExp),
        medianGdpPercap = median(gdpPercap))

# Use a scatter plot to compare the median GDP and median life expectancy
ggplot(by_continent_2007, aes(x = medianGdpPercap, y = medianLifeExp, color = continent)) +
    geom_point() +
    expand_limits(y = 0)

ggplot(gapminder_1952, aes(x = continent, y = gdpPercap)) +
  geom_boxplot() +
  scale_y_log10() +
  ggtitle("Comparing GDP per capita across continents")

	geom_col()
	goem_histogram()