Skip to content
Introduction to Data Visualization with ggplot2
Introduction to Data Visualization with ggplot2
Run the hidden code cell below to import the data used in this course.
# Load the Tidyverse
library(tidyverse)
# Load the course datasets
diamonds <- read.csv("datasets/diamonds.csv")
iris <- read.csv("datasets/iris.csv")
iris_tidy <- read.csv("datasets/iris_tidy.csv")
iris_wide <- read.csv("datasets/iris_wide.csv")
recession <- read.csv("datasets/recession.csv")
fish <- read.csv("datasets/fish_species.csv")
fish_tidy <- read.csv("datasets/fish_tidy.csv")
fish_year <- read.csv("datasets/fish_year.csv")Take Notes
Add notes about the concepts you've learned and code cells with code you want to keep.
Add your notes here
# Set the color scale
palette <- brewer.pal(5, "RdYlBu")[-(2:4)]
# Add a title and caption
ggplot(gm2007, aes(x = lifeExp, y = country, color = lifeExp)) +
geom_point(size = 4) +
geom_segment(aes(xend = 30, yend = country), size = 2) +
geom_text(aes(label = round(lifeExp,1)), color = "white", size = 1.5) +
scale_x_continuous("Highest and lowest life expentancies, 2007", expand = c(0,0), limits = c(30,90), position = "top") +
scale_color_gradientn(colors = palette) +
labs(caption = "Source: # Add your code snippets here