-
Notifications
You must be signed in to change notification settings - Fork 0
/
vignette.Rmd
42 lines (32 loc) · 997 Bytes
/
vignette.Rmd
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
39
40
41
42
---
title: "TidyVerse"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
```
## The Best NBA Players, According To RAPTOR.
*file latest_RAPTOR_by_player.csv contains RAPTOR data for every player in the latest season.*
```{r, warning=FALSE}
df = read_csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/nba-raptor/modern_RAPTOR_by_player.csv",
col_names = TRUE)
head(df)
```
## 1A: basic ggplot
poss - Possessions played
mp - Minutes played
```{r}
df %>% ggplot(aes(x = mp, y = poss)) +
geom_col(fill = "lightblue")
```
## 1B: How do I flip coordinates?
```{r}
df %>% ggplot(aes(x = mp, y = poss)) +
geom_col(fill = "lightblue") + coord_flip()
```
## 2A: How do I change sort order?
```{r}
ggplot(df, aes(x = fct_reorder(player_name, poss), y = poss)) +
geom_col(fill = "lightblue") + coord_flip()
```