Solutions: https://www.paulamoraga.com/book-r/99-problems-ggplot2-practice-solutions.html
Dataset ggplot2::economics_long
. Variables
date
, value
, variable
.
Dataset ggplot2::mpg
. Variables displ
,
hwy
, cyl
.
geom_gitter()
to add a small amount of random variation
to the location of each pointhrbrthemes
for additional packages: https://hrbrmstr.github.io/hrbrthemes/library(tidyverse)
library(hrbrthemes)
library(viridis)
<- data.frame(name = c(rep("A", 500), rep("B", 500), rep("B", 500), rep("C", 20), rep('D', 100)),
d value = c(rnorm(500, 10, 5), rnorm(500, 13, 1), rnorm(500, 18, 1), rnorm(20, 25, 4), rnorm(100, 12, 1)))
library(tidyverse)
library(viridis)
library(ggplot2)
library(gganimate)
library(babynames)
library(hrbrthemes)
# Keep only 3 names
<- babynames %>% filter(name %in% c("Ashley", "Patricia", "Helen")) %>% filter(sex == "F") d
library(ggplot2)
library(gganimate)
<- data.frame(group = c("A","B","C"), values = c(3,2,4), frame = rep('a', 3))
a <- data.frame(group = c("A","B","C"), values = c(5,3,7), frame = rep('b', 3))
b <- rbind(a,b)
d
ggplot(a, aes(x = group, y = values, fill = group)) + geom_bar(stat = 'identity')