-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path01_inclass_exercise.qmd
More file actions
38 lines (29 loc) · 880 Bytes
/
Copy path01_inclass_exercise.qmd
File metadata and controls
38 lines (29 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
title: "Learn R: Interactive plots with ggplot2 and ggiraph"
format: html
editor: visual
editor_options:
chunk_output_type: console
---
Welcome to your Quarto notebook for today's workshop! This is where you will try out the hands-on exercise.
```{r}
# load packages
library(tidyverse)
library(ggiraph)
```
### A. Load data
```{r}
# load data
bowie <- read_csv("data/david_bowie_spotify.csv")
```
### B. Your Turn!
Make the following plot `p1` interactive. Add a tooltip showing `track` and highlight tracks from the same `album` on hover.
**Bonus:** Using `paste0()` and `"<br>"`, replace the tooltip with year, track name, and album name (each on their own line)
```{r}
p1 <- bowie |>
ggplot(aes(x = year, y = popularity)) +
geom_point(color = "maroon",
alpha = .7, size = 2) +
theme_minimal()
```
###