Excerpt from the Gapminder data, as an R data package and in plain text delimited form
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
## so jittered figs don't always appear to be changed
set.seed(1)
This repo is a data package with an excerpt from the Gapminder data.
The main object in this package is the gapminder
data frame or “tibble”.
There are other goodies, such as the data in tab delimited form, a larger unfiltered dataset, premade color schemes for the countries and continents, and ISO 3166-1 country codes.
The primary use case is for teaching and writing examples.
Install gapminder
from CRAN:
install.packages("gapminder")
Here we do a bit of data aggregation and plotting with the gapminder
data:
library(gapminder)
library(dplyr)
library(ggplot2)
aggregate(lifeExp ~ continent, gapminder, median)
gapminder %>%
filter(year == 2007) %>%
group_by(continent) %>%
summarise(lifeExp = median(lifeExp))
ggplot(gapminder, aes(x = continent, y = lifeExp)) +
geom_boxplot(outlier.colour = "hotpink") +
geom_jitter(position = position_jitter(width = 0.1, height = 0), alpha = 1 / 4)
For more, see the Get started vignette.